I have the following situation. I am uploading multiple files to the server but I need that once the file is on the server it shows me the name of the one that was uploaded and so on with the ones that follow. The process is being done through ajax and php . The files upload without problem but the message I receive is the last file and not while they are uploading. I leave the code to see if you can help me.
Thank you
HTML
<div id="myModalmultpl" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Subir doctumento</h3>
</div>
<div class="modal-body">
<?php echo for_open('#', array('class' => 'form-signin', 'id' =>'form-polizam')); ?>
<div id="idsubiendo"></div>
<input type="file" name="uploadfile[]" id="uploadfile[]" multiple />
<input type="hidden" name="tipoupload" id="tipoupload" value="1" >
<input type="button" name="submit" id="idsubmit" value="Subir">
<?php echo for_close(); ?>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Cerrar</button>
</div>
</div>
JavaScript
$("#idsubmit").on('click', function () {
try {
//obtenemos un array con los datos del archivo
var dataString = new FormData($("#form-polizam")[0]);
$.ajax({
url: 'index.php?c=gpagar&f=setgdrive',
type: 'POST',
data: dataString,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
beforeSend: function () {
$("div#idsubiendo").html('<div class="alert alert-success"><b>Subiendo ...</b></div>');
},
//una vez finalizado correctamente
success: function (data) {
console.log(data);
bootbox.alert("<h6>El fichero ha sido subido al Google Drive: "+data.error+"</h6>");
},
//si ha ocurrido un error
error: function (data) {
console.log(data);
$("div#idsubiendo").html('');
bootbox.alert("A ocurrido un error por favor contacte con el administrador");
}
});
} catch (err) {
bootbox.alert(err);
}
});
php
foreach($datos as $val){
unset($_SESSION['idPol']);
$nombre = $val['name'];
$ext = pathinfo($nombre, PATHINFO_EXTENSION);
$aNombre = explode("-",$nombre);
$fecha = $aNombre[0]."-".$aNombre[1]."-".$aNombre[2];
//Traemos el id del movimiento.
$idmov = preg_replace('/[^0-9]+/','', $aNombre[4]);
$objMov = $gpa->get_movAutoId($idmov, $fecha);
$_SESSION['idPol'] = $objMov->id;
//Conformamos el nombre del fichro
$nameFile = $gpa->set_namefile($objMov->id_mov);
$path = "lib/gdriver/files/";
$nom = $path.$nombre;
$nom2 = $path.$nameFile.".".$ext;
rename($nom, $nom2);
//Extraemos el id de la empresa.
$obj = $emp->get_empresaNomId($aNombre[3]);
$fileid = $gpa->set_datagdrive($nameFile.".".$ext, $obj->id, $fecha);
$jdata['error'] = $fileid;
echo json_encode($jdata);
}