Jump to content

[SOLVED] Displaying Images stored in a db with PHP


CodeMama

Recommended Posts

I am having big difficulties getting my stored images to show up, the images are there, I can echo the properties, but when I try and display them, nada, anyone see where I'm going wrong?

Here is the embedded tag for the image on my display page (as you can see I have tried it several different ways in case my mistake is here) :

  <a href="image.php?filename=<?php echo$row['photoName']; ?>"><?php echo$row['photoName']; ?></A><br>
              
              <?php echo "\n<br>Scout Photo : "."<img src=\image.php?filename=" .$row['photoName']. "\">"; ?>
              
              
              <?php echo "<img src=\"image.php?filename=".$row['photoName']."\">\n"; ?>
              
              <?php echo "<img src=\"image.php?id=".$row['ePID']."\">\n"; ?>
              
              <img src="image2.php?filename=<?php echo $row['photoName']; ?>">

???

 

 

Here is the code from my image.php page (the one that is supposed to set the right headers to display the image)

 

include("inc/dbconn_open.php");
error_reporting(E_ALL);


//if (isset($_FILES['ePhoto'])){$ePhoto = $_FILES['ePhoto'];} else {$ePhoto ="";}

$filename = $_GET['$filename'];

$image = stripslashes($_REQUEST[photoName]);

$sql = "SELECT ePhoto, photoName, photoType from eagleProjects WHERE photoName = $filename";
$result=mysql_query($sql);
$data = mysql_fetch_array ($result);



$type = $data['photoType'];
$name = $data['photoName'];

   header("Content-type: $type");
   header("Content-Disposition: attachment; filename=$name");

   
echo $data["photoName"];
echo $data["ePhoto"];

exit;

 

thanks in advance if anyone can figure this out, I am getting burnt out!!  ??? :'(

the script to show your image should echo nothing more than that field from the database and set the headers...

 

this should give you the pointers http://www.phpriot.com/articles/images-in-mysql/8 - note that the script uses id's to grab the data rather than the filename itself.

Thanks I did change it to use the ID ...still nothing, I am starting to wonder if it's a server / headers issue or something ..I'm lost and been working on this all day, thankfully I get to leave the office in one more hour...here is what my image.php page looks like now:

 

$ePID = $_GET['$ePID'];

$image = stripslashes($_REQUEST[photoName]);

$sql = "SELECT ePhoto, photoName, photoType from eagleProjects WHERE ePID = ".$_GET['ePID']." ";
$result=mysql_query($sql);
$data = mysql_fetch_array ($result);



$type = $data['photoType'];
$name = $data['photoName'];

   header("Content-type: $type");
   header("Content-Disposition: attachment; filename=$name");
   

echo $data['ePhoto'];

exit;

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.