Home  >  Article  >  Backend Development  >  How to solve the problem that php cannot upload images

How to solve the problem that php cannot upload images

藏色散人
藏色散人Original
2020-07-29 09:54:103057browse

Solution to the problem that php cannot upload images: first open the "php.ini" configuration file; then open "file_uploads" and set "memory_limit"; then set the maximum allowed execution time of each script; finally save the changes. Can.

How to solve the problem that php cannot upload images

Recommended: "PHP Tutorial"

php.ini configuration file (the following points)

1. Whether file_uploads is turned on. It must be turned on to allow HTTP file uploads;

Determine the upload size post_max_size = 8M (server side)

2. Accepted by PHP Maximum POST data length (client) To upload large files, this value must be greater than "upload_max_filesize" If memory limit is activated in the configuration script, "memory_limit" also affects file uploads.

Generally speaking, "memory_limit" should be larger than "post_max_size". The maximum size of uploaded files upload_max_filesize = 1204KB

3. The maximum allowed execution time of each script, measured in seconds Parameters help prevent low-quality scripts from endlessly hogging server resources.

Note: "max_execution_time" only affects the running time of the script itself. Any other time spent outside of script running, such as the use of system()/sleep() functions, database queries, file uploads, etc. are not included.

In safe mode, you cannot use ini_set() to change this setting at runtime. The maximum allowed time for each script to receive input data (POST, GET, upload), set in seconds. The maximum number of memory bytes that can be applied for. This helps prevent bad scripts from consuming all the memory on the server. To use this directive, it must be enabled at compile time.

The above is the detailed content of How to solve the problem that php cannot upload images. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn