cURL requesting URL with whitespaces in URL.. What to do

后端 未结 5 1914

So I\'m trying to curl this URL:

http://images.fastcompany.com/upload/Screen shot 2011-04-28 at 8.13.21 PM.png

URL Encoded it reads as:

http%3

相关标签:
5条回答
  • 2021-01-07 17:18

    Just use str_replace.

    echo str_replace ( ' ', '%20', 'http://images.fastcompany.com/upload/Screen shot 2011-04-28 at 8.13.21 PM.png' );
    
    0 讨论(0)
  • 2021-01-07 17:27

    Perhaps try replacing spaces with %20?

    0 讨论(0)
  • 2021-01-07 17:41

    I use:

    $link = trim($link);
    $link = str_replace ( ' ', '%20', $link);
    
    0 讨论(0)
  • 2021-01-07 17:44

    Use the str_replace(); function. Replace your " " with "%20"

    0 讨论(0)
  • 2021-01-07 17:45

    For me just to put the name with spaces between "" worked.

    Example

    curl --upload-file "001- name - lastName.pdf" https://transfer.sh/ernesto
    

    Notice the use of "" in "001- name - lastName.pdf"

    0 讨论(0)
提交回复
热议问题