How can I allow JS set HTML <input type='file'> value

2423 views
Skip to first unread message

ZhiCheng Lee

unread,
Jul 3, 2020, 8:30:15 AM7/3/20
to Chromium HTML5
Chrome Tell me that Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string When I cry to edit value via JS

PhistucK

unread,
Jul 3, 2020, 8:32:57 AM7/3/20
to ZhiCheng Lee, Chromium HTML5
I believe this is by design. Do other browsers behave differently?

You cannot have a value in a file input if there is no file to back it up.
Web developers cannot programmatically load a path to the file input, as that will allow them to read arbitrary files off the persistent memory of the user, including personal, security or otherwise sensitive information.

PhistucK


On Fri, Jul 3, 2020 at 3:30 PM ZhiCheng Lee <ptlizh...@gmail.com> wrote:
Chrome Tell me that Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string When I cry to edit value via JS

--
You received this message because you are subscribed to the Google Groups "Chromium HTML5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-html...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-html5/40da851d-d1f1-4631-a5dd-b3364bdf47cbo%40chromium.org.
Reply all
Reply to author
Forward
0 new messages