An error occurred while processing multiple files in php.

Source: Internet
Author: User
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']

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.