Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/103033-linking-to-an-image-from-a-subfolder/
Share on other sites

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

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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.