First go to the source code, you can copy it to your own computer and run it ~
Copy the code The code is as follows:
Multiple file upload< /title>
/ /Upload file information
$img = $_FILES['img'];
if ($img)
{
//File storage directory, 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 uploaded Success, preview
if($state)
{
echo "
";
}
}
$i++;
}
}
?>
move_uploaded_file() function
The move_uploaded_file() function moves the uploaded file to a new location. Returns true if successful, false otherwise.
Usage: move_uploaded_file(file,newloc)
Parameter file, required. Specifies the files to be moved.
Parameter newloc, required. Specifies the new location of the file.
This function checks and ensures that the file specified by file is a legal upload file (that is, uploaded through PHP's HTTP POST upload mechanism). If the file is legal, it is moved to the file specified by newloc.
If file is not a legal uploaded file, no operation will occur and move_uploaded_file() will return false.
If file is a valid uploaded file but cannot be moved for some reason, no action will occur and move_uploaded_file() will return false and a warning will be issued.
This check is particularly important if the uploaded file may cause its content to be displayed to the user or other users of this system.
Note: This function is only used for files uploaded via HTTP POST.
Note: If the target file already exists, it will be overwritten.
http://www.bkjia.com/PHPjc/323970.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323970.htmlTechArticleFirst upload the source code, you can copy it to your own computer to run ~ Copy the code as follows: html meta http- equiv="Content-Type" content="text/html; charset=utf-8" head title on multiple files...