2

How do you preset the filepath in a input type=file?

I want the field to already have a path in it -> Read-Only possibly?

asked Sep 21, 2011 at 0:59

2 Answers 2

2

You can not preset the input[type=file] element.

The only reliable thing you can do is read back the filename with the value property on the DOM. Some browsers prepend a fake path, e.g. C:\fakepath\some-file.jpg.

answered Sep 21, 2011 at 1:00
Sign up to request clarification or add additional context in comments.

Comments

2

You can't do that, it's a security issue. Doing so would let a web site operator create a form with a hidden file field, with a path filled in, so that when the user submits the form the browser would also upload a file of the website operator's choosing.

answered Sep 21, 2011 at 1:01

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.