I have the following code
$allowed = array('png', 'jpg', 'gif','zip');
if(isset($_FILES['upl']) && $_FILES['upl']['error'] == 0){
$extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);
if(!in_array(strtolower($extension), $allowed)){
echo '{"status":"error"}';
exit;
}
else{
$nomesImagens = (isset($_COOKIE['nomesImagens'])) ? $_COOKIE['nomesImagens'] : '';
if (empty($nomesImagens)) {
setcookie("nomesImagens", $_FILES['upl']['name'], time()+300, "/");
}
else{
$novoNome = $_COOKIE['nomesImagens'].",".$nomesImagens;
setcookie("nomesImagens", $novoNome, time()+300, "/");
}
$tmpImagens = (isset($_COOKIE['tmpImagens'])) ? $_COOKIE['tmpImagens'] : '';
if (empty($tmpImagens)) {
setcookie("tmpImagens", $_FILES['upl']['tmp_name'], time()+300, "/");
}
else{
$novoNome = $_COOKIE['tmpImagens'].",".$tmpImagens;
setcookie("tmpImagens", $novoNome, time()+300, "/");
}
}
}
echo '{"status":"error"}';
exit;
For each selected image it preloads the image and stores the tmp_name and name of the image in cookies through an ajax request, however at the time of inserting the whole form, the input files are added so I have to insert the cookies which I have already recorded, it inserts into the bank but does not allocate the images, is it possible to do this with temporary files?