开发者

Expalanation for errors in the below code

开发者 https://www.devze.com 2023-04-05 04:38 出处:网络
if(!is_dir($dir_path)) { $mk_dir=mkdir($dir_path, 0777); $ch_mod=chmod($dir_path, 0777); } In the above code I am get开发者_Go百科ting errors like below:
if(!is_dir($dir_path))
    {
        $mk_dir=mkdir($dir_path, 0777);
        $ch_mod=chmod($dir_path, 0777);
    }

In the above code I am get开发者_Go百科ting errors like below:

Warning: mkdir() [function.mkdir0]: No such file or directory in E:\salaahakardb\New Folder\xampp\htdocs\extramarks2\jnrcontent\fillblanks\form_vars.php on line 66

Warning: chmod() [function.chmod0]: No such file or directory in E:\salaahakardb\New Folder\xampp\htdocs\extramarks2\jnrcontent\fillblanks\form_vars.php on line 67

Please explain


The parent directory of the directory you're trying to create probably doesn't exist.

One way could be to create it recursively:

mkdir($dir_path, 0777, true);

Check http://php.net/manual/en/function.mkdir.php for further info.

Also you can get rid of that chmod() since you are already setting permissions while mkdir()'ing.


is_dir function returns false, if passed parameter is file - it's your situation. try file_exists function

0

精彩评论

暂无评论...
验证码 换一张
取 消