Use the jQuery Upload plugin. In the plugin files there is an example class for image upload. But it's very complex.
To get the data that this plugin send, you can use the same specified in the manual .
When a form is submitted, the $_FILES['userfile']
, $_FILES['userfile']['name']
, and $_FILES['userfile']['size']
arrays are initialized.
Let's suppose you upload review.html
and xwp.out
files using the following form
<form action="file-upload.php" method="post" enctype="multipart/form-data">
<input name="userfile[]" type="file" /><br />
<input name="userfile[]" type="file" /><br />
<input type="submit" value="Enviar" />
</form>
In this case, in $_FILES['userfile']['name'][0]
will have the value review.html
and $_FILES['userfile']['name'][1]
will have xwp.out
.
The other file variables also have the same behavior
$_FILES['userfile']['size'][0]
$_FILES['userfile']['name'][0]
$_FILES['userfile']['tmp_name'][0]
$_FILES['userfile']['size'][0]
$_FILES['userfile']['type'][0]
Using this you can implement an upload class that suits you, and you can use the plugin I mentioned.
Another way I think is more feasible for you is to send the zipped file.
You can read the compressed files using ZipArchive
// Criando o objeto
$z = new ZipArchive();
// Abrindo o arquivo para leitura/escrita
$open = $z->open('teste.zip');
if ($open === true) {
// Listando os nomes dos elementos
for ($i = 0; $i < $z->numFiles; $i++) {
// Obtendo o conteúdo pelo indice do arquivo $i
$fileContent = $z->getFromIndex($i);
// Aqui você faz o parser do XML e realiza sua manipulação
}
// Fechando o arquivo
$z->close();
} else {
echo 'Erro: '.$open;
}
Learn more about ZipArchive