1. Multiple attribute is added to the form field in the form form form to upload multiple files in a single field
2. To pass in information of multiple files in the form of array, you need to set the name property to: example: name = "post []"
3. Verify and save multiple files to disk as arrays
4. In the data receiver, loop through the receiving
//Upload multiple files in a single file domain
$pos_type = $_FILES['poster']['type'];
$pos_err = $_FILES['poster']['error'];
$pos_name = $_FILES['poster']['name'];
$pos_size = $_FILES['poster']['size'];
//All of the above are arrays of corresponding file information
$arr = array();//Used to store the path. To solve the problem of Notice:Array to string conversion //Idea: to find out the problem, I directly connected the string with the array //Solution: 1) create an empty array (here is $arr) to store the path of each uploaded image 2)When traversing the file array, string("http://www.study4.com:81/unlode/") //Add to a new array (I'm here at $path) 3)When traversing the array of file names, append each file name to the $path in 4)Reuse implode("", $path);Method to name an array as a string 5)Add the modified string to the $arr This is the case. $arr It's a one-dimensional array $len = count($pos_name); //Array of types used to verify uploaded pictures $pos_arr = array("image/jpg","image/jpeg","image/gif","image/png"); for($i=0;$i<$len;$i++){ $path = array("http://www.study4.com:81/unlode/"); if(!(in_array($pos_type[$i], $pos_arr))){ $GLOBALS['error_mes'] = "Wrong image upload type"; continue; } if($pos_size[$i]<1*1024 || $pos_size[$i]>40*1024*1024){ $GLOBALS['error_mes'] = "Picture file size is unreasonable"; continue; } if($pos_err[$i] > 0){ $GLOBALS['error_mes'] = $pos_err[$i]; }else{ if (file_exists("D:/www/www5/unlode/" . $_FILES["poster"]["name"][$i])) { $path[] = $_FILES["poster"]["name"][$i]; $path = implode("", $path); $arr[] = $path; echo $_FILES["poster"]["name"][$i] . " The file already exists. "; } else { // If the file does not exist in the upload directory, upload the file to the upload directory move_uploaded_file($_FILES["poster"]["tmp_name"][$i], "D:/www/www5/unlode/" . $_FILES["poster"]["name"][$i]); echo "Files stored in: " . "D:/www/www5/unlode/" . $_FILES["poster"]["name"][$i]; } } }