Jump to content

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


merrydown

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
Link to comment
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.
Link to comment
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
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.