php - mkdir() not working with this code for creating random directory name for upload photo -


// profile picture upload if (isset($_files['profilepic'])) {     if ( ((@$_files["profilepic"]["type"]=="image/jpeg")             || (@$_files["profilepic"]["type"]=="image/png")             || (@$_files["profilepic"]["type"]=="image/gif"))         && (@$_files["profilepic"]["size"] < 1048576) ) //1 megabyte     {         $chars = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789";         $rand_dir_name = substr(str_shuffle($chars), 0, 15);          mkdir("userdata/profile_pics/$rand_dir_name"); 

this directory files are: c:/xampp/htdocs/asweb

and want keep new directory: c:/xampp/htdocs/asweb/userdata/profile_pics

i tested following:

$chars = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789"; $rand_dir_name = substr(str_shuffle($chars), 0, 15); echo $rand_dir_name.$b;    // ojtxnhb0ruiykze  mkdir("c:\\dev\\".$rand_dir_name,0777,true); 

it made c:\dev\ojtxnhb0ruiykze no problem. went in there , saved text file.

the manual page says

mode

the mode 0777 default, means widest possible access. more information on modes, read details on chmod() page.

note: mode ignored on windows. note want specify mode octal number, means should have leading zero. mode modified current umask, can change using umask().

however on linux, have follow chmod values.

edit: op can't it, here go again:

$chars = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789"; $rand_dir_name = substr(str_shuffle($chars), 0, 15); echo $rand_dir_name.$b;    // l1tgxw3kgqcr2n5 mkdir("c:\\xampp\\htdocs\\asweb\\userdata\\profile_pics\\".$rand_dir_name,0777,true);    

made c:\xampp\htdocs\asweb\userdata\profile_pics\l1tgxw3kgqcr2n5 no problem


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -