Reputation: 6720
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%3A%2F%2Fimages.fastcompany.com%2Fupload%2FScreen+shot+2011-04-28+at+8.13.21+PM.png
However, curl needs it to be decoded into a proper URL obviously.
How do i get around this problem? cURL drops off the rest of the string as soon as it reaches any whitespace... :(
I should mention I can't wrap the URL with double quotes as it is a variable being posted.
Edit: hahahahaha wowwwwww brainfart.. thanks guys :P
Upvotes: 44
Views: 102131
Reputation: 20169
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"
Upvotes: 3
Reputation: 4444
On Windows, you can use notepad++
Upvotes: 0
Reputation: 2032
I use:
$link = trim($link);
$link = str_replace ( ' ', '%20', $link);
Upvotes: 10
Reputation: 2322
Just use str_replace.
echo str_replace ( ' ', '%20', 'http://images.fastcompany.com/upload/Screen shot 2011-04-28 at 8.13.21 PM.png' );
Upvotes: 47