Php file Upload question & lt ;? Phpheader ('content-Type: & nbsp; text/html; & nbsp; charset = gbk'); echo & nbsp; '& lt; pre & gt ;'; print_r ($ _ FILES); echo & php file upload problems
Header ('content-Type: text/html; charset = gbk ');
Echo'
';
print_r($_FILES);
echo '
';
Echo'
';
If ($ _ FILES ['userfile'] ['error']> 0 ){
Switch ($ _ FILES ['userfile'] ['error']) {
Case 1: echo "script" alert ('The file uploaded exceeds the agreed value of 1'); history. back (); script ";
Break;
Case 2: echo "script" alert ('The file uploaded exceeds the agreed value of 2'); history. back (); script ";
Break;
Case 3: echo "script" alert ('partially uploaded '); history. back (); script ";
Break;
Case 4: echo "script" alert ('No files uploaded '); history. back (); script ";
Break;
}
Exit;
}
If (is_uploaded_file ($ _ FILES ['userfile'] ['tmp _ name'])
{
If (! Move_uploaded_file ($ _ FILES ['userfile'] ['tmp _ name'], 'uploads'/'. $ _ FILES ['userfile'] ['name'])
{
Echo "script alert ('moving failed! '); History. back (); script ";
Exit;
}
} Else {
Echo "script" alert ('file uploaded cannot be found in the temporary folder '); history. back (); script ";
Exit;
}
Echo "script" alert ('file uploaded successfully! '); Location. href = 'demo3. php? Url = ". $ _ FILES ['userfile'] ['name']." '; script ";
?> Why can I upload a small file correctly and display all the information of $ _ FILES? however, when uploading a large file, the S_FILES information is not displayed and the output is "Array ()", in addition, you can bypass the if ($ _ FILES ['userfile'] ['error']> 0) statement and directly prompt 'upload file not found in the temporary folder, ask the experts to explain why this problem occurs? PHP: '; print_r ($ _ FILES); echo... 'data-pics = ''>
------ Solution --------------------
The value of the max_file_uploads post_max_size memory_limit parameter in your php. ini file cannot exceed this value.
------ Solution --------------------
As mentioned above, the size of the file you uploaded exceeds the maximum file size limit in INI. in this case, the file cannot be uploaded, that is, $ _ FILES ['name'] will be an empty array. of course, $ _ FILES ['name'] ['error'] will not be greater than 0, and you will jump directly to the back.
The best solution is to cut the upload and not upload all at once. you can use ajax to split the file.
------ Solution --------------------
If post_max_size is not set, it will use the default value of 8 M. your large file must exceed 8 M, so $ _ FILES will be blank.