Jump to content

How To Create A Download File Link?


Guest artfultrillium

Recommended Posts

Guest artfultrillium

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...