Home >Backend Development >PHP Tutorial >Precautions for uploading files in PHP under Linux, _PHP tutorial

Precautions for uploading files in PHP under Linux, _PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:50:05942browse

Precautions for uploading files in PHP under Linux,

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1135009.htmlTechArticlePrecautions for uploading files in php under linux. This article shares the precautions for uploading files under php under linux for everyone. For reference, the specific content is as follows 1. Modify the upload directory permissions linux repair...
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