Add FileList constructor
Nessuno ha ancora preso questa issue.
- Lingua principale
- HTML
- Stelle
- 118
- Fork
- 52
- Merge medio
- 9g 16h
- PR unite (30g)
- 1
Descrizione
Split out from https://www.w3.org/Bugs/Public/show_bug.cgi?id=17125 :
The
<input type="file" name="something" />
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 in
- Only the browser can create one on user request (ie. by file input or drag and drop)
- JS cannot change it in any way
So it should not be a security issue to allow assignment to a file input.
For example:
<input type="file" name="something[]" onchange="splitFiles();" id="in1" multiple="multiple" />
function splitFiles() {
var in = document.getElementById('in1');
//create single inputs
for(var i=0;i<in.files.length;i++) {
var newEl = document.createElement('input');
newEl.name = "something[]";
newEl.id = '...';
newEl.type = "file";
newEl.value = in.files[i]; // <-- assignment of file object
document.appendChild(newEl); //add for upload
//create some UI to remove this input
//...
}
//remove the multi-input
in.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).
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando la richiesta relativa a FileList constructor e il comportamento di file-input, File-object, drag-and-drop e XHR descritto nell'issue. Definisci la semantica di assegnazione prevista e i criteri di completamento prima di individuare il testo pertinente della specifica o i test; l'issue non fornisce file del repository né punti di ingresso dei test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- html, javascript
- Ambito
- api, web-dev
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100