php – cURL requesting URL with whitespaces in URL.. What to do-ThrowExceptions

Exception or error:

So I’m trying to curl this URL: shot 2011-04-28 at 8.13.21 PM.png

URL Encoded it reads as:

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 😛

How to solve:

Just use str_replace.

echo str_replace ( ' ', '%20', ' shot 2011-04-28 at 8.13.21 PM.png' );


Perhaps try replacing spaces with %20?


I use:

$link = trim($link);
$link = str_replace ( ' ', '%20', $link);


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


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


curl --upload-file "001- name - lastName.pdf"

Notice the use of “” in “001- name – lastName.pdf”

Leave a Reply

Your email address will not be published. Required fields are marked *