The batch upload method is also very simple. We only need to add a name="pictures[]" array to the form, and then use foreach ($_FILES["pictures"]["error"] as $key => $error ) Loop through the array and then use move_uploaded_file($tmp_name, $uploadfile); to upload the file.
html code
The code is as follows
代码如下 |
复制代码 |
upload picture more once
|
|
Copy code
|
代码如下 |
复制代码 |
if($_POST['upload']=='Send'){
$dest_folder = "picture/";
if(!file_exists($dest_folder)){
mkdir($dest_folder);
}
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
$uploadfile = $dest_folder.$name;
move_uploaded_file($tmp_name, $uploadfile);
}
}
}
?>
|
upload picture more once |