0

I want to upload a static file on my drive like C:\someplace\somefile.doc THe file and location is always the same.

I need to do an ajax POST to a url to send this file using only javascript...

Could someone provide some idea or example how this could be done using dojo or jquery...is this possible?

I seen examples where it uses a form...but that is not I want.

thanks

2
  • you may be able to do this with javascript+flash. uploadify is a possibility: http://www.uploadify.com/about/ Commented Jun 5, 2011 at 2:14
  • Well, most modern browsers are designed to prevent JavaScript programs from accessing your local hard drive -- for very good security reasons. The only way is through the file-upload mechanism in a form. You should RETHINK whether you need this in the first place. If a JavaScript program can get a file from your hard disk, which means that somebody else can write a web page to get stuff from your computer without you knowing, or worse, wipe your hard drive clean. Commented Jun 5, 2011 at 8:57

2 Answers 2

1

you cant upload files from your local computer using javascript without using the built in upload function (the form).

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

2 Comments

they designed it this way for security reasons. or else malicious scripts could upload your harddrive without the user knowing.
form needs to be enctype="multi-part/form-data" fwiw
0

MDN has an article on how to do it:

https://developer.mozilla.org/en/Using_files_from_web_applications

Check 'Handling the upload process for a file'.

They don't use jQuery but the new HTML5 File AP and XmlHttpRequest 2.

Comments

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.