Home >Backend Development >PHP Tutorial >PHP code for uploading multiple images_PHP tutorial

PHP code for uploading multiple images_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 16:59:13925browse

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 "$filename ";
}
}
$i++;
}
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631334.htmlTechArticle provides a basic tutorial to tell you that if you use the move_uploaded_file function to upload multiple images, of course you can also upload multiple images. The file has been uploaded, I hope it helps. Provide...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn