You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionsplitFiles(){varin=document.getElementById('in1');//create single inputsfor(vari=0;i<in.files.length;i++){varnewEl=document.createElement('input');newEl.name="something[]";newEl.id='...';newEl.type="file";newEl.value=in.files[i];// <-- assignment of file objectdocument.appendChild(newEl);//add for upload//create some UI to remove this input//...}//remove the multi-inputin.parent.removeChild(in);}
This code would split a multi-file-input back to multiple single-file inputs (that way applications with a legacy backend that only supports the classical way could also support multi-file-inputs).
Another use would be with File objects obtained by drag and drop.
Right now those require XHR to upload. Allowing to make them a selection of a file input could simplify some situations as well as provide richer UI (when showing a traditional file input together with a drop area those would stay in sync).
The text was updated successfully, but these errors were encountered:
The first use case for legacy backends can't be done until whatwg/html#3269 is resolved somehow. We could use this as the File API side issue for that, as it'll need to change here eventually.
annevk
changed the title
Make input[type=file] assignable for File objects
Add FileList constructor
Dec 7, 2017
Split out from https://www.w3.org/Bugs/Public/show_bug.cgi?id=17125 :
The
element has always been readonly (you can't change value) for security purposes.
That makes sense as a string could always be manipulated by JS.
The
File
object on the other hand should be "safe", as inSo it should not be a security issue to allow assignment to a file input.
For example:
This code would split a multi-file-input back to multiple single-file inputs (that way applications with a legacy backend that only supports the classical way could also support multi-file-inputs).
Another use would be with File objects obtained by drag and drop.
Right now those require XHR to upload. Allowing to make them a selection of a file input could simplify some situations as well as provide richer UI (when showing a traditional file input together with a drop area those would stay in sync).
The text was updated successfully, but these errors were encountered: