Hi there, I am making a link which when clicked should download a jpeg file. But the normal linking tags makes the jpeg to open in the browser itself. I want that it should prompt the user to save jpeg as it does for all other files. Any ideas how can I give a link to download jpeg file instead of opening it? regards pratik
you could probably accomplish this with php, use the php include(); function to include the jpeg, and in php set the MIME type to something that would try to get downloaded... I don't know the specifics right now, if you're interested, look it up on the php website.
I'm not sure how to do it in php, but this works in perl -- maybe it's useful to you: $ImageLink = "http://path.to.com/$filename.jpg"; print "Content-Type: application/octet-stream\n"; print "Content-Disposition:attachment;filename=$filename.jpg\n"; print "Location: $ImageLink\n\n"; exit; Code (markup): Try searching for 'force file download php' or something in Google -- I think I ultimately had to work with a php script to come up with the above. It was years ago, though... so I can't remember.
Hi there, I believe that this can be done using the header tag in PHP with code similar to the following: <?php header('Content-Type: image/jpeg'); header('Content-Length: 1234'); header('Content-Disposition: attachment;filename="test.jpg"'); $fp=fopen('test.jpg','r'); fpassthru($fp); fclose($fp); ?> Code (markup): Where Content-Length should be the size of the filename. Hopefully that will work. Bex
Some users may know that rightclicking on an image allows them to save it. If not you could tell them to right click on the link and select save target as. Otherwise, the PHP methods posted above may be the way to go.
Thanks of the response guys.. but its an ASP page that I am working on.. so I guess that PHP code won't work Is there any way of doing it by simple HTML or ASP.
Effectively forcing the download of a known MIME type is a problem since browsers will open the image rather than offer a download option by rule. Best way in my opinion is to archive the image and upload it as a .zip file. That will surely do the trick.