Jump to content

Recommended Posts

So, I've managed to store a picture into a database. This happens to be a profile picture for the user.

 

I know that I'll need the query to be:

$query = mysql_query("SELECT * FROM tbl_images WHERE byuser='$id'");

 

But that's about it. Whenever I try and write up a code to display the picture I only get it displayed as a raw file, which isn't cool.

 

I heard that I can't have any html codes when I display a picture, but if this is so how is it possible to view it in my users' profile page?

 

All help appreciated!!

one way is like this

 

header('Content-Type: image/jpg');

$image=fpassthru($tag);

 

another is like this

 

foreach ($dbh->query($query) as $row)

 

        {

 

 

        $name = $row['name'] ;

        $image = $row['image_data'] ;

       

 

header('Content-type: image/jpg');

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

echo  $image;

}

 

then call the php file as such

 

<?php

 

echo"<html>";

 

echo"<head>";

 

echo"<title>Untitled 1</title>";

echo"</head>";

 

echo"<body>";

$a='images.php';

echo"<table style=\"border: medium groove #800000; width: 100%\">";

echo"<tr>";

echo "  <td style=\"border: thin ridge #800000; width: 100px\"><img src='$a/image.jpg' /></td>";

echo " <td style=\"border: thin ridge #800000; width: 100%\">Description of person</td>";

echo " <td style=\"border: thin ridge #800000; width: 100px\"><img src=images/Adobe_PDF.jpg /></td>";

echo " </tr>";

echo " </table>";

 

echo " </body>";

 

echo"</html>";

 

?>

Okay, those are great ideas, thanks! I'm confident this will solve my issue regarding the raw file.

However I also have a problem that it says that headers are already sent, so my: header('Content-type: image/jpg');

won't work. And that's sort of an essential part. Headers are already sent in a file i have included, and it has to be included, is there anyway I do something to get around this?

 

Thanks for the reply guys!

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.