For more information, please refer to the following link for more information, however, an error occurred while uploading multiple files. I don't know where the error is. please advise me. 1. & nbsp; Upload code & lt; body & gt; & nbsp; & lt; form & nbsp; actionTestReceiveFile. php
When I was a beginner in php, I found a piece of code on the Internet for uploading html files and php files. After debugging, there was no problem with uploading a single file, but there was always an error in uploading multiple files, I don't know where the error is. please advise me.
1. Upload code
2. server php code
Header ('content-Type: text/html; charset = utf-8 ');
$ FileArray = $ _ FILES ['file']; // obtain information about multiple FILES. note: The key name here does not contain []
$ Upload_dir = './upload/'; // Save the Directory of the uploaded file
Foreach ($ fileArray ['error'] as $ key => $ error ){
If ($ error = UPLOAD_ERR_ OK) {// PHP constant UPLOAD_ERR_ OK = 0, indicating no Upload error
$ Temp_name = $ fileArray ['tmp _ name'] [$ key];
$ File_name = $ fileArray ['name'] [$ key];
Move_uploaded_file ($ temp_name, $ upload_dir. $ file_name );
Echo 'upload [file '. $ key.'] successful!
';
} Else {
Echo 'upload [file '. $ key.'] failed!
';
}
}
3. Error
------ Solution ----------------------
$ FileArray = $ _ FILES ['file'] to $ fileArray = $ _ FILES ['myfile']