Skip to content
Advertisement

Mkdir do not create folder and no Errors shown. (PHP) [closed]

I need some help with mkdir in my .php file. It’s not creating the directory.

I’m currently running Centos 6.6 web server, I have all folders chmod 755 and owner = Apache.

My code is as follows:

<?php $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
   $rand_dir_name = substr(str_shuffle($chars), 0, 15);
   mkdir("../userdata/profile_pics/".$rand_dir_name);
?>

No error messages are shown and I’m 100% sure that the path /userdata/profile_pics exists.

Any help?

Advertisement

Answer

mkdir("../userdata/profile_pics/".$rand_dir_name, 0777, true);

There is also a chance you’re in a wrong directory currently. If this is the case – you need to change the current dir with chdir() or specify the full path

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement