Necesito controlar que mediante un input type="file" solamente se elija un archivo de extención ".jpg", para ello tengo esta función javascript, que conseguí en este mismo foro:
Código HTML:
extArray = new Array(".jpg");
function LimitAttach2(form, file) {
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) form.submit();
else
alert("Se permiten únicamente archivos con la extención: "
+ (extArray.join(" ")) + "\nPor favor, seleccione otro archivo "
+ "e intente de nuevo.");
}
Y esto es el formulario:
Código HTML:
<tr>
<td align="right" valign="top" style="color:#000;">Imágen / Logo:</td>
<td><input name="img" type="file" id="img" size="40"></td>
</tr>
<tr valign="top">
<td width="80px"></td>
</tr>
<tr valign="top">
<td align="center" colspan="2"><input name="send" type="button" id="send" value="Vista previa" onclick="LimitAttach2(document.form, this.form.img.value)"></td>
Tengo un grave problema con esto:
En IE funciona pero en FF no y no entiendo porque!
Por favor, espero que alguien pueda ayudarme...!
Saludos y gracias