In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces PHP how to configure large file upload, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.
PHP uses the super global variable array $_ FILES to record the information related to file upload. Before the php file is uploaded, you can control the upload details by adjusting the relevant configuration instructions in php.ini.
1.file_uploads=on/off
Is it allowed to upload files through http?
2.max_execution_time=30
Allow the maximum execution time of the script, after which an error will be reported.
3.memory_limit=50M
Set the maximum amount of memory that a script can allocate to prevent runaway scripts from consuming too much memory. This instruction can only be set at compile time.
-- it will not take effect until the enable-memory-limit flag
4.upload_max_filesize=20M
Maximum size of files allowed to be uploaded, this instruction must be less than post_max_size
5.upload_tmp_dir
Temporary storage directory for uploaded files
6.post_max_size=30M
Allow post mode to accept maximum size
The array of $_ FILES is as follows: www.jb51.net
$_ FILES ['myFile'] [' name'] the original name of the client's last file.
The MIME type of the $FILES ['myFile'] [' type'] file, which requires the browser to provide support for this information, such as "image/gif".
$_ FILES ['myFile'] [' size'] the size of the uploaded file in bytes.
The temporary file name stored on the server after the $_ FILES ['myFile'] [' tmp_name'] file is uploaded, which is generally the system default. It can be specified in the upload_tmp_dir of php.ini, but setting it with the putenv () function does not work.
$_ FILES ['myFile'] [' error'] and the status code associated with the file upload. ['error'] is added in PHP version 4.2.0. Here is its description: (they become constants after PHP3.0)
UPLOAD_ERR_OK
Value: 0; No error occurred and the file was uploaded successfully.
UPLOAD_ERR_INI_SIZE
Value: 1; the uploaded file exceeds the limit of the upload_max_filesize option in php.ini.
UPLOAD_ERR_FORM_SIZE
The size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.
UPLOAD_ERR_PARTIAL
Value: 3; only part of the file is uploaded.
UPLOAD_ERR_NO_FILE
Value: 4; No files have been uploaded.
Value: 5; upload file size is 0.
After the file is uploaded, it is stored in the temporary directory by default, and you must delete it from the temporary directory or move it somewhere else. If not, it will be deleted.
That is, regardless of whether the upload is successful or not, the files in the temporary directory will be deleted after the script is executed.
Attachment: the method of modifying the size limit of files uploaded by PHP
1. General file upload, unless the file is very small. Like a 5 m file, it will probably take more than a minute to upload.
But in php, the default maximum execution time for this page is 30 seconds. That is, after more than 30 seconds, the script stops execution.
This leads to the inability to open the web page. At this point we can modify the max_execution_time
Look for it in php.ini
Max_execution_time
The default is 30 seconds. Change to
Max_execution_time = 0
0 means there is no limit
two。 Modify post_max_size to set the maximum size allowed for POST data. This setting also affects file uploads.
The default post_max_size of php is 2m. If the POST data size is greater than post_max_size $_ POST and $_ FILES superglobals, it will be empty.
Look for post_max_size. Change to
Post_max_size = 150m
3. Many people will change the second step. But when uploading files, the maximum is still 8m.
Why。 We also need to change the parameter upload_max_filesize to indicate the maximum size of the uploaded file.
Find upload_max_filesize. Default is 8m instead of
Upload_max_filesize = 100m
It is also important to note that post_max_size is greater than upload_max_filesize.
Thank you for reading this article carefully. I hope the article "how to configure PHP for uploading large files" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.