Home > Article > Backend Development > What to do if php mkdir fails
php The solution to the failure of mkdir: first log in to the server; then authorize the directory where the folder is to be created as "chmod 777 parpath" under root; and finally run the mkdir code.
Recommended: "PHP Video 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, but something went wrong as soon as the results were uploaded to the server. After manually creating When entering the folder, no error is reported, but when I enter 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.
mkdir() function creates a directory.
This function returns TRUE if successful and FALSE if failed.
Grammar
mkdir(path,mode,recursive,context)
The above is the detailed content of What to do if php mkdir fails. For more information, please follow other related articles on the PHP Chinese website!