The first question is solved in a simple way:
<!-- language: lang-html -->
<form method="POST" enctype="multipart/form-data">
<input name="nombre_campo" type="file" accept="token_tipos_aceptados"
multiple="1" /><!-- 1 para indicar que acepta varios archivos -->
<input type="submit" name="btncargar" value="Cargar" />
</form>
Where token_tipos_aceptados
must be a space-separated string of identifiers of supported file types, conforming to the html specification recommended by W3C . When you click on browse to find the files to load, the browser will only show files of the indicated types.
If multiple=1
is specified, the browser will accept loading several files simultaneously into a single input element. But, be careful because the superglobal $ _FILES passes them with a format of arrangement quite different from the usual.