i am running an image hosting script when i upload normal images everything is fine but when i upload images with spaces in between it creates problems for eg - If i upload "Abc Vbg.jpg" The Link Comes Like This http://localhost/photo/Abc+Vbg.jpg Code (markup): But the correct link to the image is http://localhost/photo/Abc Vbg.jpg Code (markup): how do i solve this issue
Noting wrong in the link. It is urlencoded with space encoded to + sign. So if you create url for the image Abc Vbg.jpg, it is encoded to Abc+Vbg.jpg
you should always filter file names. if somebody uses filenames with weird characters in them, you might not be able to remove them from your server. use preg_replace to filter the filenames
generate new filename - replace spaces with _ and add some unique value - this will solve the problem
function cleanfile($file) { return preg_replace('/[^0-9A-Za-z\- ]/', "", $file); } PHP: that should work