What to do if php mkdir fails

藏色散人
Release: 2023-03-04 10:36:02
Original
4278 people have browsed it

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.

What to do if php mkdir fails

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 "创建目录失败!";
Copy after login

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)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template