w3c / w3c/FileAPI

Add FileList constructor

Abierto
#24 4 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

feature request TPAC2024
Lenguaje dominante
HTML
Estrellas
118
Forks
52
Merge medio
9 d 16 h
PR fusionados (30 d)
1

Descripción

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).

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza revisando la solicitud de FileList constructor y el comportamiento de file-input, File-object, drag-and-drop y XHR descrito en el issue. Define la semántica de asignación prevista y los criterios de finalización antes de localizar el texto pertinente de la especificación o los tests; el issue no proporciona archivos del repositorio ni puntos de entrada de tests.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
html, javascript
Área
api, web-dev
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.