I. If php does not limit the upload size, we can limit the upload size when uploading, as shown in
The code is as follows: |
Copy code |
$ Maxattachsize = 5097152; // maximum upload size. The default value is 2 MB. $ Temppath = $ upfile ['tmp _ name']; $ Filesize = filesize ($ temppath ); If ($ filesize> $ maxattachsize) $ err = 'File size exceeds '. $ maxattachsize.' Byte '; |
In this way, only 2 MB files can be uploaded.
2. Modify post_max_size and upload_max_filesize in php. ini.
1. memory_limit memory settings
2. max_execution_time
3. Maximum post_max_size POST data limit
4. Maximum size of uploaded files in upload_max_filesize
Example
The code is as follows: |
Copy code |
Max_execution_time = 30; Maximum execution time of each script, in seconds Max_input_time = 60; Maximum amount of time each script may spend parsing request data ; Max_input_nesting_level = 64; Maximum input variable nesting level Memory_limit = 128 M; Maximum amount of memory a script may consume (128 MB) ; Maximum size of POST data that PHP will accept. Post_max_size = 105 M ; Maximum allowed size for uploaded files. Upload_max_filesize = 100 M |
Tips: If you are uploading large files, we 'd better add the execution time set_time_limit to the page.
The code is as follows: |
Copy code |
Set_time_limit (0 ); |
In this way, no timeout will occur.