Parameters involved in file upload in PHP

Source: Internet
Author: User
Tags form post
The default size of PHP files to be uploaded is 2 MB. to upload files that exceed this setting, you need to adjust some parameters such as PHP and apache. next, we will briefly introduce some parameters involved in PHP file upload: file_uploads allows you to upload files over HTTP. by default, ON is the parameter involved in upl PHP file upload.
PHP's default upload limit is 2 MB. to upload files that exceed this setting, you need to adjust some parameters such as PHP and apache.

Number. Below, we will briefly introduce some parameters involved in php file upload:

File_uploads

Whether to allow file upload over HTTP. ON is enabled by default.

Upload_tmp_dir

Upload_tmp_dir indicates the temporary directory where PHP files are uploaded. to upload files, ensure that the server does not

Disable temporary files and write permissions on folders. if not specified, PHP uses the default system value.

Upload_max_filesize

Maximum file size that can be uploaded. the default value is 2 MB.

Post_max_size

Controls the maximum data size that PHP can receive in a form submission using the POST method. If you want to use the php file

This value must be larger than upload_max_filesize.

Max_input_time

The time for receiving data through POST, GET, and PUT is limited in seconds. If the application is running in the environment

In the low-speed link, you need to add this value to adapt to the more time required to receive data.

Memory_limit

To avoid using a large amount of available memory by running scripts, PHP allows you to define the memory usage limit. Pass

Memory_limit variable to specify the maximum memory capacity variable memory_limit value that can be used by a single script program.

When the value is greater than post_max_size

Max_execution_time

Max_execution_time sets the time for PHP to wait for the script to be executed before the script is forcibly terminated. The time is measured in seconds.

. This variable is useful when the script enters an infinite loop state. However, it takes a long time to complete

For example, uploading large files. In this case, you must consider

Increase the value of this variable to prevent PHP from closing the script when the script is executing some important processes.

For linux hosts, the php. conf file may exist in/etc/httpd/conf. d/access. conf /.

File may solve some system file size restrictions

[Edit] use discuz to upload large PHP files


The attachment function of the forum was originally designed not for file management. due to server configuration, php, network, and other aspects

This makes uploading files through the forum not a good solution.


If you really need to improve the uploading conditions of Forum attachments, you can try to set the parameters mentioned above in php. ini,

To meet the needs of uploading large files. At the same time, do not forget to set attachments in the background of the Forum.


There are two main parts of the Forum to limit the size of attachment uploads, from high to low:

Post-related --- attachment type size

User group --- attachment related

At the same time, the following provides a Configuration Guide, from some friends who have successfully uploaded large attachments through http, of course, because

Different server configurations and network conditions do not necessarily apply to your situation. you may need to modify the configuration in many places:

Open php. ini,

Parameter settings

Whether file_uploads on allows file upload over HTTP. ON is enabled by default.

Upload_tmp_dir -- upload the file to the place where the temporary file is stored on the server. If this parameter is not specified, the default

Temporary folder

Upload_max_filesize 8 m Wangwen business, that is, the maximum file size allowed to be uploaded. The default value is 2 MB.

Post_max_size 8 m refers to the maximum value that can be received by the form POST to PHP, including all values in the form. Default value:

8 M

Description

Generally, after the preceding four parameters are set, uploading a file <= 8 m is not a problem under normal network conditions.

However, if you want to upload a large file larger than 8 MB, you can only set the above four items. Unless your network actually has 100 MB/s

Or you have to set the following parameters.

Max_execution_time 600 maximum time (in seconds) for running each PHP page. the default value is 30 seconds.

Max_input_time 600 maximum time required for receiving data on each PHP page. the default value is 60 seconds.

Memory_limit 8 m maximum memory consumed by each PHP page. the default value is 8 M.

After modifying the preceding parameters, you can upload a large volume of files as permitted by the network.


[Edit] common error types for uploading Forum files (keep summing up ...)

Warning: Unable to open '\ php2' for reading: Invalid argument in e: \ user \ web

\ Larksoft.net \ upload \ upfile. php on line 10

Is the reason for php's upload_tmp_dir. the specified directory must be readable and writable.


Parse error: parse error in c: \ program files \ apache group \ apache \ htdocs \ mdweb

\ Ftpfile \ upload. php on line 14

Parse errors are generally statements, such as ";", "", and ")".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.