John
John

Reputation: 4706

Link for downloading folder

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

Answers (2)

Joachim Bharathi
Joachim Bharathi

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"

  1. upload your folder to any online file storage service provider (like Google Drive or Dropbox).
  2. Place that inside another folder say "parentfolder"
  3. Get the link for the "parentfolder" and add that into your website's HTML (make sure to change viewing setting to anyone with the link)

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

dkenkatewal
dkenkatewal

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

Related Questions