Sreed
Sreed

Reputation: 1

html + javascript: Browsing a folder using browse option

I need to have my user send the file path to the webserver. For this i'm trying to use input file type so that user can select the file. Please note that I don't want do uploading the file. I just need the location of some file. So user should be able to do that using browse option. I know that due to some security reasons in browsers, full path is not sent to server. But can we acheive this some way. I've observed that using input type=file after user selects some file using browse option (as it is not possible to select folder), the Firefox sends the server just the filename and IE sends fullpath of file including file name.

Please note that this website is used internally so it is not a security problem at all, so don't bother about security and all.

is there anyway we can acheive this?

Thanks in advance, Sreed

Upvotes: 0

Views: 3872

Answers (3)

macguru2000
macguru2000

Reputation: 2132

Browsers do not let you save or even see the full file path to a selected file from the <input type="file" /> form element. I would recommend Flash or Java for your needs. You could also have the user manually type in the full path...just a thought.

Upvotes: 0

Pekka
Pekka

Reputation: 449475

No, sadly I don't think there is.

All modern browsers will send a C:\Fakepath path. To my knowledge, this behaviour can not be changed for local networks in any browser.

I'm not sure what the state of things is for Flash-based uploaders like SWFUpload or Uploadify. Flash traditionally gives more control over such data than the native browser controls. (Edit: Uploadify seems to give you the file path. See this question: How can I get the uploaded file details from uploadify after completion however, this of course is after a completed upload, which is not what you want.)

A Java applet based solution will be able to do this, but I expect the effort to implement this is huge.

I would consider using a normal text file, and asking the user to just copy+paste the correct path.

Upvotes: 1

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114377

You need to use something that has access to the filesystem. BY DESIGN javascript/html cannot do this. You need to use flash, java or a browser plug-in.

Upvotes: 1

Related Questions