0

I want upload the file using HTML file control but without selection dialog since i have to upload file which has fixed path "c:\finsts\finstmt.xml".

Scenario 1:
I have tried to upload file using HTML control . In which it shows browse button and on click you have to select file from file chooser dialog box. It works. Its upload file to server fine. Server side code is correct and works fine.

Scenario 2:
But when I hide the file chooser control, with following HTML code:

 <div name="filediv" style="display:none">
  <html type="file" id="uploadfile" value="c:\finsts\finstmt.xml">  
 </div>

As file path is fixed and I don't want to user select file. When I tried with this scenario it doesn't work while first works fine. I don't understood how file control works.

Anyone here knows any work around to work the second scenario?

Thanks.

2
  • 2
    You probably meant <input type="file" … Commented Jan 22, 2011 at 16:23
  • The potential for abuse of such a feature is huge - for that reason you can't do this. Commented Jan 22, 2011 at 16:23

3 Answers 3

5

This is not possible for security reasons. There is no workaround.

It used to be possible using a Flash-based uploader, but even Flash requires an explicit user file selection now for the same reasons.

You may have a chance using a Java applet or a proprietary VBScript that works in Internet Explorer only (and requires the site to be in the trusted zone), but it's going to be complex.

Sign up to request clarification or add additional context in comments.

Comments

2

First of all, there is no <html type="file" at all.
Second, this is not possible, because of security restrictions...
You can't access arbitrary files on users' computer via the browser, you can only ask the user to select a file of their choice.

Comments

0

The best choice you have is to put the file name you desire in text directly above the file chooser, and tell your users to cut and paste it into the file box. You might even be able to get a little js tool that a user can click and fill the copy buffer so they only have to hit paste.

note: I am not proposing that javascript populate the file upload box directly using a 'copy/paste' trick. I'm proposing a UI where helping the user populate the box with the least amount of effort is the only approach you can take due to the security requirements in the browser.

1 Comment

Interesting idea, but this seems no longer possible at least in Google Chrome and Firefox. They will force open the selection dialog in any case

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.