Hi I'm trying to put a link on my webpage to download a file. For example (for a jpg image), instead of linking directly to an image to have it open in a browser window, I'd like to have a link that will cause the jpg file to download to the user's computer. Is there a way to do this or should I put instructions on the webpage for users to right click and use "save target as..." ? thanks
you could put it in a zip file and link to that, that way it'll automatically start to download. you probably have a zipping utility on your computer, but if not use a free zip archiver like zipgenius or go to download.com and do a search for zip utilities, zip archiver, or something.
ok thanks I might try that but a lot of websites have direct download links to files (PDFs for example). Is there some way I can do this directly from my site without using a zip file?
the zip file will be directly from your site, but you can just instruct them to right click on the file to download.
ok thanks I might try that but a lot of websites have direct download links to files (PDFs for example). Is there some way I can do this directly from my site without using a zip file?
files with .jpeg extensions associated as images (shows as content) in browsers by default, so there is no way to make it "downloadable directly". as for pdf - it is another file type not viewable in browser. so, you need to use "right click - save" way, as bob25 said
actually you can right click on the image and choose "Save Image As" and download it that way, but you need to right ON the image. you can make PDF's downloadable i think by using software like DLGuard.com. try emailing the owner he's very responsive.
You can use the AddType directive to force a file download! Add the following code to your .htaccess file: AddType application/octet-stream .jpg Code (markup): This code sends the correct content type for a JPEG image, sends the file size then tells the browser to offer a download dialog with the suggested name "test.jpg". <?php header('Content-Type: image/jpeg'); header('Content-Length: 1234); header('Content-Disposition: attachment;filename="test.jpg"'); $fp=fopen('an_image.jpg','r'); fpassthru($fp); fclose($fp); ?> PHP: Or use another method: http://sn.vc/forcedownload