Home>Article>Backend Development> How to solve the problem of php mkdir failure under Linux
The solution to the failure of php mkdir: first create the folder manually in the background; then log in to the server; then authorize the directory to be created as "chmod 777 parpath" under root; finally run the code. .
Recommended: "PHP Tutorial"
Solution to PHP mkdir failure under Linux
I recently made a website, and the user needed to manually create folders in the background. After the website was written, it ran very well under Windows. However, as soon as the results were uploaded to the server, something went wrong. After manually creating the files, When entering the folder, no error is reported, but when entering that directory, I cannot see the corresponding folder created. There must be a problem with the code execution.
The code is as follows:
mkdir($path,0777); if(file_exists($path)) echo "目录创建成功!"; else echo "创建目录失败!";
I suspected it was a permissions issue, so I logged in to the server and authorized the directory where the folder was to be created under root: chmod 777 parpath, and then ran the code, everything was ok!
Note: parpath is the parent directory and path is the subdirectory to be created.
The above is the detailed content of How to solve the problem of php mkdir failure under Linux. For more information, please follow other related articles on the PHP Chinese website!