Prita Hasjim
Prita Hasjim

Reputation: 343

Select folder location in HTML input

I looked around and I can't seem to find the answer I need. Is there a way to select the location of a folder in an HTML input? I looked at this post but the answer is uploading the files in the selected folder.

I am trying to create something where the user can choose an output folder on his/her computer where files will be downloaded to. So I need something where the user can browse his/her computer, select a folder, and the location string ("C://...") will show up on the input text box.

Please let me know. Thanks!

Upvotes: 1

Views: 7588

Answers (1)

Sven Schürmann
Sven Schürmann

Reputation: 612

No on clientside with plain html and javascript it isn't possible. Your browser handle file downloads. So you can only specify download location in the browser settings!

There are solutions for IE and Chrome but this is very browser specific:

For chrome you can use FSO.js, which is a JavaScript library for temporary and permanent client-side file storage.

In IE you can create an ActiveXObject like this:

// initialize ActiveXObject and create an object of Scripting.FileSystemObject.  
var fso = new ActiveXObject("Scripting.FileSystemObject");  

// creates a folder with specified name at the specified location  
fso.CreateFolder("C:\\Temp\\myFolder");  

fso = null; 

Upvotes: 1

Related Questions