Simple PHP multi-graph Upload of small program code. First, run the source code. you can copy it to your computer to run it ~ Copy the code as follows: htmlmetahttp-equivContent-Typecontenttexthtml; charsetutf-8headtitle multi-file first on the source code, you can copy to your computer to run ~
The code is as follows:
Multi-file Upload
// Upload file information
$ Img = $ _ FILES ['IMG '];
If ($ img)
{
// File storage directory, which is the same as the 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 "";
}
}
$ I ++;
}
}
?>
Move_uploaded_file () function
The move_uploaded_file () function moves the uploaded file to the new location. If yes, true is returned. otherwise, false is returned.
Usage: move_uploaded_file (file, newloc)
Parameter file, required. Specifies the file to be moved.
Required. Specifies the new location of the file.
This function checks and ensures that the file specified by the file is a valid file to be uploaded (that is, the file is uploaded through the http post Upload mechanism of PHP ). If the file is valid, it is moved to the file specified by newloc.
If the file is not a valid Upload file, no operation is performed. move_uploaded_file () returns false.
If the file is valid but cannot be moved for some reason, no operation will occur. move_uploaded_file () will return false, and a warning will be issued.
This check is especially important. if the uploaded file may display the content to the user or other users in the system.
Note: This function is only used for files uploaded through http post.
Note: If the target file already exists, it will be overwritten.
Bytes ~ The code is as follows: html meta http-equiv = "Content-Type" content = "text/html; charset = utf-8" head title multi-file...