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!!  ??? :'(

Link to comment
Share on other sites

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;

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.