Jump to content

Archived

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

merrydown

Displaying images from database and saving as with the right name!

Recommended Posts

Hi, I am storing images in a database for use on a website.  The problem is that when I try to save an image I am displaying on the page, the script name is the save name. (  The image src is typically: "view.php?imageID=3&size=thumb".  The code / headers in the script view.php which displays the images are:

if (!empty($row_imageRS['image'])){
    // Output the MIME header
    header("Content-Type: {".$row_imageRS['mimeName']."}");
$latifah=$row_imageRS['name'];
if ($_GET['size']=='main') {
// Output the image
    echo $row_imageRS['image'];}
if ($_GET['size']=='thumb') {
// Output the image
    echo $row_imageRS['thumb'];}
}

My question is, how do I get the displayed image to right-click save as $row_imageRS['name'] ?

Cheers for any help offered!

Jim

Share this post


Link to post
Share on other sites
Don't store the images in the database.
Store the images in a folder on the server, reference that with the name of the image, and hte path.
It's a lot easier, cleaner, and a whole lot better on performance.

Share this post


Link to post
Share on other sites
Thanks for the advice.  Point taken.  Is there a way to pass the name though?  On the size of system I am dealing with, the performance hit isn't a big deal and I'd just like to know if anyone can help me?

Share this post


Link to post
Share on other sites
You can't do what you are wanting from the database.

THe way you see people being able to right click on a file, and save file as, is when the file is on the server, that way the server can recognize the file type naturally and allow there browser to do that.

As I said as long as you are doing it that way you are stuck, there are a lot of reasons you don't want to put images/files into a database.
Even text files.

I would rewrite your system, it would allow a lot more functionality in the future, and also get you what you are trying to do naturally just by displaying a link to the path location of the file directly through the html.

Share this post


Link to post
Share on other sites
Thanks for the explanation businessman, it wasn't explicit in your initial post that it wasn't possible.  It sounded like you were saying it was bad practice.  It won't take much work to do it the other way, I converted it from file storage to database in the first place, so no biggy.

Cheers again, Jim

Share this post


Link to post
Share on other sites

×

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.