The size limit of PHP files to be uploaded. post_max_size affects the size of files and its solution-Ai found a problem during the php Upload operations today, that is, when the size of files uploaded by php exceeds the size of php files. when the post_max_size limit is set in ini, the page does not provide a reminder, and the file upload fails. this problem may be an alternative. I will share it with you today.
The following parameters affect the file size uploaded by php. ini:
Function description
File_uploads ON determines whether the PHP script ON the server can Upload HTTP files
Memory_limit 8 M sets the maximum memory size that can be allocated by the script to prevent out-of-control scripts from occupying the server memory exclusively.
Upload_max_filesize 2 M limits the maximum number of uploaded files processed by PHP. this value must be smaller than the value of post_max_size.
Post_max_size 8 M limit the maximum amount of information that can be accepted through the POST method
The error message corresponding to the error in $ _ FILES is:
File upload errors
0: indicates that no error has occurred and the file is uploaded successfully.
1: indicates that the size of the uploaded file exceeds the limit of the upload_max_filesize option in the PHP configuration file.
2: The size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.
3: indicates that the file is only partially uploaded.
4: indicates that no file is uploaded.
From this we can see that php can only make judgments on the restrictions of the upload_max_filesize configuration item, but there is no corresponding judgment on the post_max_size configuration item. in this case, the page is actually in a crashed state and no prompt is given on the page.
To solve this problem, the current method is to get the post_max_size configuration value through the ini_get () function, and then send it to the front-end for verification at the front-end. Another method is to directly verify in the background and use ini_get () to obtain the value of post_max_size, and then compare it with the file to be uploaded. However, you must first obtain the file size through ajax.
Qq: 411200871 (aiweiaike technology), if you have a good way to communicate with each other.