Guest artfultrillium Posted March 21, 2012 Share 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? Quote Link to comment Share on other sites More sharing options...
Brother Hassan Posted March 21, 2012 Share Posted March 21, 2012 http://stackoverflow.com/questions/5720297/html-code-to-download-an-imageMaybe this will help you better understand. Quote Link to comment Share on other sites More sharing options...
Guest artfultrillium Posted March 28, 2012 Share Posted March 28, 2012 Quote Link to comment Share on other sites More sharing options...
Brother Hassan Posted March 28, 2012 Share 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. Quote Link to comment Share on other sites More sharing options...
Ice IT Support Posted March 28, 2012 Share 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. Quote Link to comment Share on other sites More sharing options...
Guest artfultrillium Posted April 2, 2012 Share Posted April 2, 2012 Quote Link to comment 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.