Question

I have to make a website for a school project and i want to a download link to a local .zip-file. I tried it with this code:

<a href="/Wallpaper.zip" download="Wallpaper.zip" class="MenuButton"/span>Download here</a>

The problem is: When i click on the button on the website it opens Finder window instead of (re)downloading to my download directory.

Can you give me some advice how i could do this: "redownload" a file on my hard drive to my download directory with HTML/CCS?

Thank you for your help and sorry if there are some mistakes in this, because im new to stack overflow and english is not my first language.

Was it helpful?

Solution

In order to download something, there needs to be a webserver involved. If you're just opening the .html file by double clicking on it, everything is loaded from the local file system. Since the file is already on your file system and you're linking directly to it, the file is opened directly from its location on disk. If you set up a webserver and open the site via a URL, the file will download.

OTHER TIPS

Are you sure you have the complete path in the href? If a folder is missing, the file won't be found.

This brief article has an example: see how it has the /files/ folder there?

<!-- will download as "expenses.pdf" -->
<a href="/files/adlafjlxjewfasd89asd8f.pdf" 
   download="expenses.pdf">Download Your Expense Report</a>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top