Jump to content

Displaying an image from directory


Fuzzy Wobble

Recommended Posts

Ok guru's. I am new to php and having some troubles with something that should be relatively simple. I am trying to read an image file from a directory and display it in an html table. The catch is, the directory is not a set variable because it depends on the user who is logged in . this directory is called "$imagedirectory" below and is passed through a SESSION.

for example $imagedirectory = "/htdocs/page/members/johnny_tracks/images/imagefile.jpg"

 

the area of concern is highlighted below <img src=\"$imagedirectory\"/>

 

I have checked that the directory is correct AND that the file exists. I have no clue how to show the image, every I run it the output is either nothing or "/htdocs/page/members/username_tracks/images/imagefile.jpg".

 

 

 

 

 

$imagedirectory = $_SESSION["rename"];

while (($out = mysql_fetch_array($rs2, MYSQLI_ASSOC))&&($i<=7))
{
$trackname = $out['track'];
$original_artist = $out['original artist'];
$genre = $out['genre'];
$style1 = $out['style1'];
$style2 = $out['style2'];
$style3 = $out['style3'];
$type = $out['type'];
$date = $out['date'];
$downloads = $out['downloads'];

echo (" <table width='600' border='0' class='tables'> <font color='#0066ff' size=1> 
<tr>
<td width='50' rowspan='3'> [color=red]<img src=\"$imagedirectory\"/> [/color]</td>
  <td width='200'><font color='#ffffff' size=1> $trackname </td> 
<td width='115'><font color='#ffffff' size=1> $genre </td>  
<td width='90'> <font color='#0066ff' size=1>$style1 </td> 
<td width='115'> </td>
<td width='20' rowspan='3'><img src='PNG_IMAGES/sample.png' /></td>
</tr>
<tr>
<td width='200'> <font color='#705698' size=1> $DJname </td> 
<td width='115'> <font color='#705698' size=1> $array[0] </td>  
<td width='90'> <font color='#0066ff' size=1>$style2 </td> 
<td width='115'> <font color='#705698' size=1> $downloads </td>
</tr>
<tr>
<td width='200'> $original_artist </td> 
<td width='115'> $size2 MB </td>  
<td width='90'> <font color='#0066ff' size=1>$style3 </td> 
<td width='115'><a href='www.break.com'>DOWNLOAD</a>  </td>
</tr><span class='style30'>&nbsp<br>
</table>

  ");
  $i++;
}

 

EDITED BY akitchin:  code tags are there for a reason.  please use them.

Link to comment
https://forums.phpfreaks.com/topic/66057-displaying-an-image-from-directory/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.