...

View Full Version : echoing GET variable strips "%20" from string



glynster
08-14-2007, 11:28 PM
Hi

I am trying to echo a get variable simply to get an image submitted via a form (cant use POST for other reasons) dislayed on the following page. SImply like this...

<img src="images/<?php echo $_GET['image']; ?>"

Problem is that if the image uploaded has a name such as:

"my%20image%20upload.jpg" (i.e. it has %20 instead of white space)

The the GET echo strips out the %20's to give me html code like:

<img src="my image upload">

...and ebcause the image is saved on the server as my%20image%20upload.jpg it therefore wont display

Anybody got any advice how to get around this?

Thanks

Glynster

_Aerospace_Eng_
08-14-2007, 11:32 PM
Do a string replace

<?php echo str_replace(' ','%20',$_GET['image']); ?>

whizard
08-14-2007, 11:46 PM
or, for a more complete solution (works for more than just spaces)

urldecode($_GET['image']);

HTH
Dan

_Aerospace_Eng_
08-15-2007, 12:02 AM
Hmm forgot about that function. Dan's suggestion is the better solution.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum