Analysis of error messages in PHP development file upload tutorial

This requires us to look at it in conjunction with the php.ini file

Open the php.ini file and search for upload

3.png

##Look at the following and ask us to put 882 Change the On line to off and then restart the server

Then run, the effect is as follows:

4.png

Output an empty array

887 line upload_tmp_dir = Directory where temporary files are stored

Line 891 upload_max_filesize = 2M The size of files allowed to be uploaded is 2 MB

Line 894 uploads = 20 The maximum number of files allowed to be uploaded at one time is 20

So we write the error message as a switch statement

switch ($error){

        case 1: echo "The uploaded file exceeds the value of upload_max_filesize in the php configuration file"; break;
                case 2: echo "The uploaded file exceeds max_file_size";break;
case 3: echo "The file was partially uploaded";break;
case 4: echo "No file was selected to upload";break;
case 6: echo "Temporary directory not found";break;
case 7:
case 8: echo "System error";break;
}

What kind of error message appears when the form is submitted , we will give you a prompt


Continuing Learning
||
<?php echo "错误信息"; ?>
submitReset Code