mike12255 Posted April 22, 2009 Share Posted April 22, 2009 Im getting the following error on a page: Warning: getimagesize(/images/product029.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/schoolw1/public_html/showproduct.php on line 111 the url is: http://schoolworkanswers.com/showproduct.php?id=86 and if you add /images/product029.jpg after the schoolworkanswers.com/ it brings you to the picture so i dont know why its not working ill post my code below and i'd appriciate if somone could tell me what im doing wrong. <?php //take the .. off the first slash in the path $path = str_replace("..","",$pd_path); //set the width and hight to vars list($w, $h) = getimagesize($path); //is the width bigger then our table? if ($w < 660){ echo "<td align=center><img src=$pd_path width= height= alt=><td>"; }else{ //this one resizes the width of the pic so the table dosnt expand. echo "<td align=center><img src=$pd_path width=650 alt=><td>"; } ?> Link to comment https://forums.phpfreaks.com/topic/155270-solved-getimagesize-cant-find-the-image/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 22, 2009 Share Posted April 22, 2009 A leading slash / on a URL refers to the domain root. A leading slash on a file system path (which is what getimagesize()) is being given, refers to the root of the current hard disk. You need to give the getimagesize() function a path to where the file is at on the disk. Use either a relative path to the image from where the script is at or an absolute path on the disk. Link to comment https://forums.phpfreaks.com/topic/155270-solved-getimagesize-cant-find-the-image/#findComment-816939 Share on other sites More sharing options...
mike12255 Posted April 23, 2009 Author Share Posted April 23, 2009 what do you mean by relative path? Link to comment https://forums.phpfreaks.com/topic/155270-solved-getimagesize-cant-find-the-image/#findComment-816968 Share on other sites More sharing options...
mike12255 Posted April 23, 2009 Author Share Posted April 23, 2009 please answser, i got a buisness meeting very shortly Link to comment https://forums.phpfreaks.com/topic/155270-solved-getimagesize-cant-find-the-image/#findComment-817746 Share on other sites More sharing options...
Bauer418 Posted April 23, 2009 Share Posted April 23, 2009 Place a period "." in front of the first slash, making the path: "./images/product029.jpg" or simply remove the first slash and period. The reason is because the / refers to the root of the directory structure. The period is a reference to "this folder" similar to the way that the double periods refer to "parent folder." In other words, if you are currently in path: /var/www/display.php and you say: require("/content.php"); you will try to load the file /content.php, though surely what you want is to load /var/www/content.php. Sort of difficult to explain, and I'm trying to get back to you within your time frame. Link to comment https://forums.phpfreaks.com/topic/155270-solved-getimagesize-cant-find-the-image/#findComment-817751 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.