The example in this article shares the precautions for uploading files under PHP under Linux for your reference. The specific content is as follows
1. Modify upload directory permissions
Linux changes the permissions of all subdirectories under a certain directory
chmod -R 777 html
Modify a directory to give any user write, read and execute permissions
chmod a rwx html
2. Set the root directory of uploaded files
//Get the project root directory
$siteRoot = dirname(__file__);
3. Modify the upload size of the configuration file php.ini
post_max_size = 200M
upload_max_filesize = 200M
4. If you want to create folders based on time and then upload files, you need to do the following
$aimUrl = str_replace('', '/', $aimUrl); $aimDir = ''; $arr = explode('/', $aimUrl); foreach ($arr as $str) { $aimDir .= $str . '/'; if (!file_exists($aimDir)) { mkdir($aimDir); chmod($aimDir, 0777); } }
The above is the entire content of this article. I hope it will be helpful to everyone in learning PHP programming.