Home  >  Article  >  Backend Development  >  What should I do if linux php cannot upload a folder?

What should I do if linux php cannot upload a folder?

藏色散人
藏色散人Original
2021-09-12 10:36:122047browse

Solution to the problem that linux php cannot upload a folder: 1. Create an upload_tmp folder in the mount directory; 2. Set "upload_tmp_dir=" to "website/upload_tmp"; 3. Restart apache. .

What should I do if linux php cannot upload a folder?

The operating environment of this article: linux5.9.8 system, PHP7.1 version, DELL G3 computer

linux php cannot upload the folder What should I do?

php cannot upload files (Linux server)

Today I discovered that files could not be uploaded suddenly. The configuration of php.ini is already.

Environment: linux (Centos 5.3) Apache php mysql

Website directory file: Use smb to mount the disk array share of the windows server

Website directory permissions: 777

php.ini :

---------------------------------------- ----------------

upload_max_filesize = 200M
max_file_uploads = 20
post_max_size = 200M
max_execution_time = 60000
max_input_time = 6000
;max_input_nesting_level = 64
memory_limit = 256M

-------------------------------- --------------------------

But the CMS system keeps prompting that there is insufficient permission. Check the relevant information to learn about php There is a parameter in the .ini file that specifies a temporary folder (all uploaded files will be placed in the temporary folder)

That is:

--------- --------------------------------------------------

;upload_tmp_dir =

------------------------------------------------ ----

The above is commented by default, that is, virtual memory will be used for storage

When the memory is full, there will be a problem that the file cannot be uploaded, that is, a prompt will appear. 777 error

Use the df - h command to query and find the following results:

-------------------------- -------------------------------------------------- ----------

/dev/mapper/VolGroup00-LogVol00
                       29G 28G 0 100% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 1014M 0 1014M 0% /dev/shm
//192.168.1.100/website 322G 21G 301G 7% /www/web/website

--------------------------------- -------------------------------------------------- -----

tmpfs is full, so I changed it to create an upload_tmp folder in the mount directory, and set the "upload_tmp_dir =" to "upload_tmp_dir =/www/web/ website/upload_tmp

After saving, restart apache and resume uploading.

Note: Give the uploaded directory 777 permissions including the following subdirectories chmod -R 777 Directory name

Summary:

It is best to set the temporary file to the mounted disk space (preferably larger), because the default value of tmpfs will be 1/2 times the physical memory , it will be full soon after uploading several files, which will cause the files to fail to be uploaded. Therefore, when configuring various website environments, you should pay attention to the directory where temporary files are stored.

Recommended learning: "PHP Video Tutorial

The above is the detailed content of What should I do if linux php cannot upload a folder?. 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