Conocimientos básicos de los controles de carga:
El control de carga (<input type = "file"/>) se usa para navegar y cargar archivos en el cliente. Asignado a través de JavaScript, lo que hace que no se puede borrar mediante la declaración de valor = "". Es fácil entender por qué es de solo lectura.
JS obtiene el valor de <intput type = file />
Copiar código del código de la siguiente manera:
<html>
<script language = 'javaScript'>
función show () {
var p = document.getElementById ("file1"). valor;
document.getElementById ("S"). InnerHtml = "<Input id = PIC Type = Image Height = 96 Width = 128 />";
document.getElementById ("pic"). src = p;
alerta (p);
}
</script>
<Evista>
<title> myhtml.html </title>
</ablo>
<Body>
<input type = "file" name = "file1" id = "file1" onpropertychange = "show ();"
<span id = "s"> </span>
</body>
</html>
Dos formas de borrar el valor del control de carga (<input type = "file"/>)
Método 1:
Copiar código del código de la siguiente manera:
<span id = span1>
<input name = AB type = file>
</span>
<input name = button1 type = button value = "Press" onClick = show ()>>
<Script Language = JavaScript>
función show ()
{{
document.getElementById ("span1"). innerhtml = "<input name = ab type = file>";
}
</script>
Método 2:
Copiar código del código de la siguiente manera:
función clearFileInput (archivo) {
var form = document.createElement ('Forma');
document.body.appendChild (formulario);
// Recuerde la ubicación del archivo en el formulario anterior
var pos = file.nextsibling;
form.appendChild (archivo);
form.reset ();
pos.parentnode.insertbefore (archivo, pos);
document.body.removechild (formulario);
}