Reputation: 4706
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?
Upvotes: 4
Views: 8365
Reputation: 26
I don't think there's a way to create a direct link to download a folder, But this is a great alternative if you want users to download your "my_folder"
You'll probably want to set :
target="_blank"
in your 'a' tag
Now, when user clicks the link it redirects to your drive and shows "my_folder" which they can either download or open to see the "my_file"
Upvotes: 0
Reputation: 86
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.
Upvotes: 4