Jump to content

Recommended Posts

Guest artfultrillium
Posted

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?

Posted

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.

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...