0

Is it possible to set a variable for an input file element value, so it could further be assigned to another input?
This is, how it works with text inputs:

var tempValue = document.getElementById('text').value;  
Eduard Climov
  • 165
  • 1
  • 15

1 Answers1

1

Basically, this is a popular question, so you can find it at these links (1, 2, 3).

But no, it is impossible – value property of input:file is read-only for security reasons – you can do it only on server-side. To read contents of the file, you have to use FileReader and specify how to read content (as plain text, as binary, or as a Blob) – example of reading as a Blob.

Community
  • 1
  • 1
Bloomca
  • 1,784
  • 13
  • 17