Home  >  Article  >  Backend Development  >  Implementation principle and code of PHP multi-file upload function_PHP tutorial

Implementation principle and code of PHP multi-file upload function_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:11:56853browse

Today I did a little research on the multi-image upload function, and sorted out the following code to facilitate my own use in the future and for everyone to communicate
1. Upload.html page, that is, the file with input type=file:

Copy code The code is as follows:



< ;title>





Picture upload
First picture

Second The third picture

The third picture

The fourth picture

The fifth picture







2. do_upload.php page, which is the page that handles multiple file uploads :
Copy code The code is as follows:

//Global array $_FILES
//$_FILES[ 'userfile']['tmp_name']The location where the file is temporarily stored in the web server
//$_FILES['userfile']['name']The file name in the user system
//$_FILES[' userfile']['size']The byte size of the file
//$_FILES['userfile']['type']The MIME type of the file, text/plain, image/gif
//$_FILES[ 'userfile']['error'] Error code related to file upload
?>
//Use a for loop to get the passed data, which is a three-dimensional data
for ($i=0;$i{
$upfile=$new_folder."/".$_FILES[' userfile']['name'][$i];//You can modify this according to your own needs
if(move_uploaded_file($_FILES['userfile']['tmp_name'][$i],$upfile) ){
echo "No.".($i+1)."Picture uploaded successfully
";
}
else{
echo "No.".($i+1 )."Unable to upload picture
";
}
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326834.htmlTechArticleToday I did a little research on the multi-image upload function and sorted out the following code to facilitate my own use in the future. And for everyone to communicate 1. upload.html page, that is, input type=f...
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