Warm tip: This article is reproduced from serverfault.com, please click

Link for downloading folder

发布于 2012-10-31 23:53:50

I have a folder my_folder, and inside of that folder is a file my_file. I would like to create a link Download my folder on my website, so that when the user clicks on it, the user's file directory comes up and the user can choose where to put my_folder (which contains my_file.) How can I implement this functionality?

I know that to allow the user to download a file, I can simply link to that file. But what about a folder?

Questioner
John
Viewed
0
dkenkatewal 2012-11-01 08:02:35

From personal experience I have not seen a way to download a whole directory. You would probably have to dynamically zip the folder up and make the resulting zip downloadable.

In HTML 5 you could use something like this to download a single file

<a href="/files/name-of-pdf.pdf" download="name-of-pdf">Download Your PDF</a>

The download attribute will force a download dialog for the user.

Hope this puts you on the right track and maybe someone can prove me wrong on that directory download.