vikaspa Posted February 10, 2009 Share Posted February 10, 2009 I am using following fucntion to get proportionate width for user specific height However I noticed that in case image name is having space it gives an error Example Function works ok for image name say "pict1.jpg" However gives error for pict 1.jpg (space in name beforer 1) list($width, $height, $type, $attr) = getimagesize(addslashes($imagename)); if ($width ==0) {$imgstr="No Image"; } else { $h=$height*($reqwidth/$width) ; if ($width > $reqwidth) { $imgstr="<img src='".addslashes($imagename)."' width=".$reqwidth." height=".$h." border=0 >";} else { $imgstr="<img src='".addslashes($imagename)."' width=".$width." height=".$height." border=0 >";} } return $imgstr; } Quote Link to comment https://forums.phpfreaks.com/topic/144583-help-to-get-get-image-size-for-images-having-space-in-their-name/ Share on other sites More sharing options...
andy_b42 Posted February 10, 2009 Share Posted February 10, 2009 i think the problem might be that spaces are no recognised url characters, try adding this line: $imagename = str_replace(" ", "%20", $imagename); before list($width, $height, $type, $attr) = getimagesize(addslashes($imagename)); this will replace spaces with %20which is the url character for a space Quote Link to comment https://forums.phpfreaks.com/topic/144583-help-to-get-get-image-size-for-images-having-space-in-their-name/#findComment-758742 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.