TRemmie Posted September 16, 2008 Share Posted September 16, 2008 Hi, I am using Flash and PHP and www.fpdf.org to allow users to upload images to my webserver, and then repoint it into the FPDF code and generate a PDF with the image. I figured that all out, however, if the user selectes an Image and it has a space (ie. desktop/folder/image 1.jpg) it errors. However, if they choose something like image_1.jpg, image-1.jpg, image1.jpg, it works it like a dream. Here is my code: $imagepath="www.webserver.com/files/"; $imagename=$_REQUEST['catcher']; $pdf->Image($imagepath . $imagename, 1.7551, 5.4792, 3.5, 2.33); Where $_REQUEST['catcher']; is the name of the file they picked in flash, and is carried as a variable. Now I was thinking is there a way to do like.... 1.) A IF statement saying if there is a space, insert a _ , - or something? No idea how that would look. 2.)Possibly breaking it down again and doing: $imagepath="www.webserver.com/files/"; $imagename=$_REQUEST['catcher']; $finalimage = $imagepath . $imagename; $pdf->Image($finalimage, 1.7551, 5.4792, 3.5, 2.33); or something like that? Anyways... Any help would be super appreciated! Link to comment https://forums.phpfreaks.com/topic/124551-solved-image-upload-if-it-has-a-space-it-errors/ Share on other sites More sharing options...
DarkWater Posted September 16, 2008 Share Posted September 16, 2008 $imagename = str_replace(' ', '-', $_POST['catcher']); Don't use $_REQUEST, use $_POST or $_GET depending on how you have it set up. Link to comment https://forums.phpfreaks.com/topic/124551-solved-image-upload-if-it-has-a-space-it-errors/#findComment-643285 Share on other sites More sharing options...
rarebit Posted September 16, 2008 Share Posted September 16, 2008 Have you tried encoding / decoding the spaces, depending upon 'exactly' where the error occurs. Is the server a *nix system? Link to comment https://forums.phpfreaks.com/topic/124551-solved-image-upload-if-it-has-a-space-it-errors/#findComment-643313 Share on other sites More sharing options...
TRemmie Posted September 16, 2008 Author Share Posted September 16, 2008 DarkWaters solution seems to have fixed it. Thanks everyone Link to comment https://forums.phpfreaks.com/topic/124551-solved-image-upload-if-it-has-a-space-it-errors/#findComment-643350 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.