simmsy Posted January 22, 2012 Share Posted January 22, 2012 Hi im having trouble with uploading images with spaces in as they dont show up in the browser. Here is the code: $image = addslashes($_FILES['image']['name']); $target = "images/"; $target = $target . basename( $_FILES['image']['name']); //Writes the photo to the server if(move_uploaded_file($_FILES['image']['tmp_name'], $target)) { Any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/255533-problem-with-white-spaces-on-image-file-upload/ Share on other sites More sharing options...
ManiacDan Posted January 22, 2012 Share Posted January 22, 2012 What do you mean they don't show up in the browser? Quote Link to comment https://forums.phpfreaks.com/topic/255533-problem-with-white-spaces-on-image-file-upload/#findComment-1310103 Share on other sites More sharing options...
simmsy Posted January 22, 2012 Author Share Posted January 22, 2012 the photos that are images/white lillies.jpg, dont appear on the browser and show up as an x on them Quote Link to comment https://forums.phpfreaks.com/topic/255533-problem-with-white-spaces-on-image-file-upload/#findComment-1310143 Share on other sites More sharing options...
litebearer Posted January 22, 2012 Share Posted January 22, 2012 show the portion of your code where you are (1) getting image name to display, and (2) displaying the image Quote Link to comment https://forums.phpfreaks.com/topic/255533-problem-with-white-spaces-on-image-file-upload/#findComment-1310154 Share on other sites More sharing options...
simmsy Posted January 23, 2012 Author Share Posted January 23, 2012 $image = addslashes($_FILES['image']['name']); $target = "images/"; $target = $target . basename( $_FILES['image']['name']); //Writes the photo to the server if(move_uploaded_file($_FILES['image']['tmp_name'], $target)) { Quote Link to comment https://forums.phpfreaks.com/topic/255533-problem-with-white-spaces-on-image-file-upload/#findComment-1310251 Share on other sites More sharing options...
ManiacDan Posted January 23, 2012 Share Posted January 23, 2012 That's the same code you already showed us, and it's not (1) getting image name to display, or (2) displaying the image Quote Link to comment https://forums.phpfreaks.com/topic/255533-problem-with-white-spaces-on-image-file-upload/#findComment-1310328 Share on other sites More sharing options...
simmsy Posted January 24, 2012 Author Share Posted January 24, 2012 its getting the name just not displaying the image but it is displaying the images without any spaces in them Quote Link to comment https://forums.phpfreaks.com/topic/255533-problem-with-white-spaces-on-image-file-upload/#findComment-1310623 Share on other sites More sharing options...
litebearer Posted January 24, 2012 Share Posted January 24, 2012 This is the 3rd request that you "show code where you are (1) getting image name to display, and (2) displaying the image". Quote Link to comment https://forums.phpfreaks.com/topic/255533-problem-with-white-spaces-on-image-file-upload/#findComment-1310634 Share on other sites More sharing options...
ManiacDan Posted January 24, 2012 Share Posted January 24, 2012 Perhaps you don't understand what we're asking. The code you're showing us is used to move the uploaded file to a permanent storage location. You need to show us code that includes an <img> tag, that's the code that displays the image. Quote Link to comment https://forums.phpfreaks.com/topic/255533-problem-with-white-spaces-on-image-file-upload/#findComment-1310638 Share on other sites More sharing options...
simmsy Posted January 25, 2012 Author Share Posted January 25, 2012 Ah I get you now! Well I select it from the mysql table its been saved to and is: "<div id='profileimage'><img src=".$image." width='200px' height='200px'></div> " but after looking at the source code the hyperlink is stopping at the white space in the title "<img src=http://www.fightwatcher.com/images/Blue "stops here! then no hyperlink after here!"hills.jpg width='200px' height='200px'></div> Quote Link to comment https://forums.phpfreaks.com/topic/255533-problem-with-white-spaces-on-image-file-upload/#findComment-1311033 Share on other sites More sharing options...
ManiacDan Posted January 25, 2012 Share Posted January 25, 2012 It's not stripping anything, tag attributes must be quoted. "<div id='profileimage'><img src=\"".$image."\" width='200px' height='200px'></div> " Quote Link to comment https://forums.phpfreaks.com/topic/255533-problem-with-white-spaces-on-image-file-upload/#findComment-1311054 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.