merrydown Posted October 17, 2006 Share Posted October 17, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/24241-displaying-images-from-database-and-saving-as-with-the-right-name/ Share on other sites More sharing options...
Ninjakreborn Posted October 17, 2006 Share Posted October 17, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/24241-displaying-images-from-database-and-saving-as-with-the-right-name/#findComment-110196 Share on other sites More sharing options...
merrydown Posted October 17, 2006 Author Share Posted October 17, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/24241-displaying-images-from-database-and-saving-as-with-the-right-name/#findComment-110206 Share on other sites More sharing options...
Ninjakreborn Posted October 17, 2006 Share Posted October 17, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/24241-displaying-images-from-database-and-saving-as-with-the-right-name/#findComment-110208 Share on other sites More sharing options...
merrydown Posted October 17, 2006 Author Share Posted October 17, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/24241-displaying-images-from-database-and-saving-as-with-the-right-name/#findComment-110252 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.