Although you can use a similar technique to reject oversized files (by checking the $uploadedfile_size variable), this is usually not a good idea. Before this variable is obtained, the file has been uploaded and saved in the temp directory. If you try to reject a file upload because of disk capacity or bandwidth, the fact that the large file is still uploaded (although they are immediately deleted) may be a problem for you.
The better way is that you can tell PHP ahead of time the upper limit of the size of the file you want to accept.
there are two methods.
The first one is to adjust the upload_max_filesize settings in your php.ini file. The default value is 2MB, so if you want to accept larger files, you need to change this value immediately.
The second method is to include an implicit input field in your form, whose name is Max_file_size, in which you can define the size of the largest file you can accept. For security reasons, this value cannot exceed the Upload_max_filesize setting in your php.ini file, but it provides a way to define the maximum size of the uploaded file on different pages. For example, the following form allows us to upload only 1k bytes of files (1024 bytes):
Copy CodeThe code is as follows:
http://www.bkjia.com/PHPjc/327813.html www.bkjia.com true http://www.bkjia.com/PHPjc/327813.html techarticle Although you can use a similar technique to reject oversized files (by checking the $uploadedfile_size variable), this is usually not a good idea. Before you get this variable, this article ...