Input file preset with a file path
How do you preset the filepath in a input type=file?
I want the field to already have a path in it -> Read-Only pos开发者_开发知识库sibly?
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
.
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.
精彩评论