Guest artfultrillium Posted March 21, 2012 Posted March 21, 2012 I would like to create some pages on my website where someone can download some image files I have made by clicking a link and that box comes up that asks if you want to save or open the file. When I do what other people have said to: <a href="http://www.mysite.com/file-name.file-extension" target="_blank">Download PNG</a> and click on the link it brings up a page showing the image instead of a box that lets them download it. What am I doing wrong?
Brother Hassan Posted March 21, 2012 Posted March 21, 2012 http://stackoverflow.com/questions/5720297/html-code-to-download-an-imageMaybe this will help you better understand.
Brother Hassan Posted March 28, 2012 Posted March 28, 2012 Thank you, that does help to explain the problem. Does anyone know if thier is a pre-writen code that would make the image be downloaded instead of displayed after clicking a link to it?I've read that you can't do this with HTML/CSS. If someone with Php knowledge can help then perhaps you can do it.
Ice IT Support Posted March 28, 2012 Posted March 28, 2012 Create a php document named "download.php" with this code: <?php header("Content-Disposition:attachment;filename='$_GET[file]'"); ?> <html> <body> <p>Your file is downloading... </body> </html> The link would look like this: <a href="download.php?file=*FILENAME*">Download file/image</a> Filling *FILENAME* with the file to download, including the file extention.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now