Home >Backend Development >PHP Tutorial >PHP code for uploading multiple images_PHP tutorial
A basic tutorial is provided to tell you that if you use the move_uploaded_file function to upload multiple images, you can also upload multiple files. I hope it will be helpful to you.
A basic tutorial is provided to tell you that if you use the move_uploaded_file function to upload multiple images, you can also upload multiple files. I hope it will be helpful to you.
Multiple file upload
//Upload file information
$img = $_FILES['img'];
if ($img)
{
//The file storage directory is at the same level as this php file
$dir = dirname(__file__);
$i = 0;
foreach ($img['tmp_name'] as $value)
{
$filename = $img['name'][$i];
if ($value)
{
$savepath="$dir$filename";
$state = move_uploaded_file($value, $savepath);
//If the upload is successful, preview
if($state)
{
echo " ";
}
}
$i++;
}
}
?>