Help - Search - Members - Calendar
Full Version: Making an image downloadable
Forums > Resource Center > Webmasters' Corner > Webmasters' Corner Resolved Topics
miiszxclassiic
Anyone know a code for making an image (or text) downloadable when you click it? Not a zip file ...just a regular download that saves to the computer
SinfullySweet
Upload your file to any number of file hosting sites, and just copy the and paste the downloadable link. I hate zip files too wink.gif
lovescream
Well usually if it's on a hosting site or anything, it'd still be an image. mellow.gif I don't know what'd work, but just tell them to simply right click and save as. >_>
tripvertigo
no, just LINK the image, in an anchor tag (<a href="http://yoursite.com/yourimage.jpg">download image </a>)
dannyordinary
QUOTE(tripvertigo @ Jul 15 2007, 03:12 PM) *
no, just LINK the image, in an anchor tag (<a href="http://yoursite.com/yourimage.jpg">download image </a>)


yep, that'll open the image in a new window
and you can download it from there
=]
miiszxclassiic
yeh i know all that already I was trying to get around that because I have my whole site in an iframe, so when you click any link thats set to open in a new window it opens in my iframe anyway but the broswer address stays the same.... in other words if i have a clickable link to someones site their whole site opens up in my iframe but the broswer address stays as my site name.

I have different php pages with wordpress and had a no right click code in the header and I couldn't figure out how to make this one page right clickable so ppl can save stuff. I tried taking the code out the header.php and putting the code on all the pages that i wanted to disable right clicking and highlighting but that didn't work ,but ohh well I guess i have some fixing to do. Thanks for the suggestions.
ExtremeGimp
If you set up the targets for the links right they should ALL open in your iframe...
I mean, I'm assuming that your iframe (e.g. named content) is set as your default target for all links...

When setting up a link try using
CODE
<a href="http://www.yoursite.com" target="_blank">LINK</a>


I saw you said you were using PHP... but I've never used that properly so don't know what the equivelent would be =\
tripvertigo
theres just no reason to be using php and iframes on the same site. it's called "includes." Look it up.

iframes just shouldnt be used ever again, in my opinion. BAD.
threepointone
There is a way to do it, and it involves either PHP / some sort of server side scripting or a server setting, which I'd doubt your host would allow. Personally I usually work with ASP, so I don't know the exact syntax for PHP, but look through the PHP reference for setting something called the MIME type. If you can have the php file send the image file (so your image is downloaded directly by the php file, such as image.php?image=thingy.jpg without any redirects or html), set the MIME type to "application/octet-stream". Additionally, you'll also need to set the content-disposition header, as described here: http://support.microsoft.com/kb/260519 (doesn't show PHP syntax, though).

A simpler way would be to have a server setting so that all jpeg files in, say, the "downloads" folder will automatically have the MIME type and content-disposition header set as described above.

I wish I could give you a more specific example, but unfortunately I'm not much of a PHP coder =(
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.