<input type=”hidden” name=”MAX_FILE_SIZE” value=”30000″ />
Be sure your file upload form has attribute enctype=”multipart/form-data” otherwise the file upload will not work.
Files will, by default be stored in the server’s default temporary directory, unless another location has been given with the upload_tmp_dir directive in php.ini. The server’s default directory can be changed by setting the environment variable TMPDIR in the environment in which PHP runs. Setting it using putenv() from within a PHP script will not work. This environment variable can also be used to make sure that other operations are working on uploaded files, as well.
The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.
|file_uploads||“1”||PHP_INI_SYSTEM||PHP_INI_ALL in PHP <= 4.2.3. Available since PHP 4.0.3.|
|upload_max_filesize||“2M”||PHP_INI_PERDIR||PHP_INI_ALL in PHP <= 4.2.3.|
|max_file_uploads||20||PHP_INI_SYSTEM||Available since PHP 5.2.12.|
max_file_uploads:一次允许上传的最大文件数量。If more files are uploaded than the limit, then $_FILES will stop processing files once the limit is reached. For example, if max_file_uploads is set to 10, then $_FILES will never contain more than 10 items.
The MAX_FILE_SIZE item cannot specify a file size greater than the file size that has been set in the upload_max_filesize in the php.ini file. The default is 2 megabytes. 表单域中的MAX_FILE_SIZE不能指定比upload_max_filesize更大的值。
post_max_size sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size. When an integer is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used. If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action=”edit.php?processed=1″>, and then checking if $_GET[‘processed’] is set.
If a memory limit is enabled, a larger memory_limit may be needed. Make sure you set memory_limit large enough.
This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. Note that to have no memory limit, set this directive to -1.
If max_execution_time is set too small, script execution may be exceeded by the value. Make sure you set max_execution_time large enough.
max_execution_time only affects the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), the sleep() function, database queries, time taken by the file upload process, etc. is not included when determining the maximum time that the script has been running.
You can not change this setting with ini_set() when running in safe mode. The only workaround is to turn off safe mode or by changing the time limit in the php.ini. Your web server can have other timeout configurations that may also interrupt PHP execution. Apache has a Timeout directive and IIS has a CGI timeout function. Both default to 300 seconds. See your web server documentation for specific details.
max_input_time sets the maximum time in seconds a script is allowed to parse input data, like POST and GET， this includes file uploads. For large or multiple files, or users on slower connections, the default of 60 seconds may be exceeded.