I did this code in HTML
<label id="read" class="read" for="files">Choose:</label>
<input type="file" accept="image/*|video/*" name="file" id="file" class="jump" multiple="true">
<input type="button" id="btlo" class="btload" name="load" value="Load" onclick="Load();">
and call function Load() below
function Load(){
var fileInput = document.getElementById("file");
var str = new FormData();
for (i = 0; i < fileInput.files.length; i++) {
str.append(fileInput.files.name, fileInput.files);
}
$.ajax({
url: "upload.php",
method: "POST",
data: str,
contentType: false,
cache: false,
processData: false,
beforeSend:function(){
$('#respimg').html("Sending...");
},
success:function(data){
$('#msgret').html(data);
}
});
}
PHP
<?php
$num = 2;
if (isset($_FILES['file'])){
for ($i = 0; $i < $num; $i++) {
$nfile = $_FILES["file"]["name"][$i];
$tfile = $_FILES["file"]["size"][$i];
$ntemp = $_FILES["file"]["tmp_name"][$i];
}
It isn´t work with o if isset but without it´s giving this mensage Notice: Undefined index: file