Jump to content

[SOLVED] Image Display


denewey

Recommended Posts

I have a very strange thing happening on something I’m developing. I don’t know whether it’s a PHP problem or HTML or something else. It is a page for a profile of a client of the web site, which allows the client to upload a photo.  I have a dummy image that’s displayed before the client uploads the image. When the client uploads the new image though, it will not display. I have verified that the image actually gets uploaded. It’s in the same directory as the dummy image. The img tag contains the same path to the new img as with the old dummy image yet the new image will not display. I’ve also verified that the database does get updated with the name of the new image. Everything seems to be as it should be, yet the image does not display. It has got me baffled!

 

Below is the text that handles the image display:

 

                <?php

$photo_display = "<img src='/photos/";

$get_photo = mysql_query("SELECT photo FROM client_profile WHERE client_id = '{$cid}'");

list ($photo) = mysql_fetch_row($get_photo);

if($photo != "")

{

$cphoto = "photos/{$photo}";

$img_size = getimagesize($cphoto);

$adjust = $img_size[0]/100;

$wide = $img_size[0]/$adjust;

$wpos = strpos($wide, ".");

if($wpos !== false)

{

$wide = substr_replace($wide, "", $wpos);

}

$high = $img_size[1]/$adjust;

$hpos = strpos($high, ".");

if ($hpos !== false)

{

$high = substr_replace($high, "", $hpos);

}

 

$photo_display .= "{$photo}' width='{$wide}' height='{$high}' />"; //THIS ONE DOESN’T DISPLAY

}

else

{

$photo_display .= "blank_head.jpg' />"; // THIS ONE DISPLAYS ON THE PAGE

}

echo $photo_display;

                    ?>

 

Does anyone have any idea what I’m running into?

???

denewey

Link to comment
Share on other sites

First its nice if you put your code in

code

 

Hit the # button above.

 

Next...

 

if ($hpos !== false)
      {
         $high = substr_replace($high, "", $hpos);
      }
      
      $photo_display .= "{$photo}' width='{$wide}' height='{$high}' />"; //THIS ONE DOESN’T DISPLAY
   }
   else

 

Wtf are {?

 

if your using a $variable you need to break out of single quotes?

 

$photo_display .= '"'.$photo.'" width="'.$wide.'" height="'.$high.'"/>';

 

or something.

Here is how i display a image from a db on a page of mine.

echo 		"<td><img src=../images/thumbs/t_".$row[image]." /></td>";

 

Link to comment
Share on other sites

Thanks for your response. To answer your question:

{} are needed for interpolating array elements and complex object references inside double quotes.

For the purpose of my script they are not needed, but another developer added them in an attempt to help me sort out this problem.

 

I tried your solution of getting everything into double quotes and that didn't work either.

 

I did discover that on the display of the page when I right click on the image and select 'view image' I get a 403 Forbidden error - "You don't have permission to access photos/xxx.jpg on this server."

Any idea what that's all about? I made sure I had the right permissions on the directories and the dummy image displays from the same directory. Is there some handling of permissions I need to do for an uploaded file?

Link to comment
Share on other sites

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.