djfox Posted April 26, 2008 Share Posted April 26, 2008 I have some pages in a subfolder that I want to display images from another subfolder. Ie: The file that calls the image is located in http://secrettrance.net/enomayrevelation/art.php The location of the image is http://secrettrance.net/gallery/Beloved Doll/00395.jpg My code is giving me a 404 error but I`ve manually looked and the file IS there. Quote Link to comment https://forums.phpfreaks.com/topic/103033-linking-to-an-image-from-a-subfolder/ Share on other sites More sharing options...
micah1701 Posted April 26, 2008 Share Posted April 26, 2008 what does the code look like? Quote Link to comment https://forums.phpfreaks.com/topic/103033-linking-to-an-image-from-a-subfolder/#findComment-527748 Share on other sites More sharing options...
djfox Posted April 26, 2008 Author Share Posted April 26, 2008 php is being used but because the problem is that the site, for whatever reason, can`t find the image, it seems to be more of an html problem. <?php if(!$offset) $offset=0; $recent = 0; $res = mysql_query("SELECT id, image, folder FROM folder_inven WHERE folder='1' ORDER BY id DESC")or die( mysql_error() ); while( $fold = mysql_fetch_row($res) ){ if( $recent >= $offset && $recent < ($offset + 24 )){ if( $recent%4 == 0 ){ echo "<tr><td><tr><td><tr><td><tr><td><tr>"; } $res2 = mysql_query("SELECT id, name, url, addDate FROM image WHERE id='$fold[1]' ORDER BY name ASC"); $image = mysql_fetch_row($res2); mysql_free_result($res2); $im = "http://secrettrance.net/$image[2]"; list($width, $height, $type, $attr, $size) = getimagesize("$im"); $size = getimagesize($im); $blah = getimagesize("$im"); $filetype = $blah['mime']; if ($filetype == 'image/jpeg') { echo "<td width=25%><center><a href='trances.php?id=$image[0]' title='$image[1] on $image[3]' target='_blank'><img src='thumbnail.php?img=$im' border=0></a>"; } elseif ($filetype == 'image/png') { echo "<td width=25%><center><a href='trances.php?id=$image[0]' title='$image[1] on $image[3]' target='_blank'><img src='thumbnail2.php?img=$im' border=0></a>"; } elseif ($filetype == 'image/gif') { echo "<td width=25%><center><a href='trances.php?id=$image[0]' title='$image[1] on $image[3]' target='_blank'><img src='thumbnail3.php?img=$im' border=0></a>"; } } $recent = $recent + 1; } ?> Here`s the error messages (condensed): Warning: getimagesize(http://secrettrance.net/gallery/Beloved Doll/00395.jpg) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/secrett1/public_html/enomayrevelation/art.php on line 32 Warning: getimagesize(http://secrettrance.net/gallery/Beloved Doll/00395.jpg) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/secrett1/public_html/enomayrevelation/art.php on line 33 Warning: getimagesize(http://secrettrance.net/gallery/Beloved Doll/00395.jpg) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/secrett1/public_html/enomayrevelation/art.php on line 34 For proof that the image does exist in that location: http://secrettrance.net/trances.php?id=1682 Quote Link to comment https://forums.phpfreaks.com/topic/103033-linking-to-an-image-from-a-subfolder/#findComment-527753 Share on other sites More sharing options...
djfox Posted April 26, 2008 Author Share Posted April 26, 2008 I`ve tried calling on the image with regular html: <img src="http://secrettrance.net/gallery/Beloved Doll/00395.jpg"> And it doesn`t appear at all. I have also tried: <img src="http://secrettrance.net/gallery/Beloved%20Doll/00395.jpg"> Quote Link to comment https://forums.phpfreaks.com/topic/103033-linking-to-an-image-from-a-subfolder/#findComment-527784 Share on other sites More sharing options...
haku Posted April 27, 2008 Share Posted April 27, 2008 This will work: <img src="http://secrettrance.net/gallery/Beloved%20Doll/00395.jpg"> As I checked, and the image existed. but you should really get in the habit of not using spaces or capital letters in file names. They just cause errors like the one you are having. So you need to first go into your server, and change the file named 'Beloved Doll' to 'beloved_doll'. You will then need to change the URL that you have saved in your database from Beloved Doll/00395.jpg' to beloved_doll/00395.jpg' This should solve your problems (or at least the initial ones. I think I see some potential problems later in your code) Quote Link to comment https://forums.phpfreaks.com/topic/103033-linking-to-an-image-from-a-subfolder/#findComment-528308 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.