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
Post a Comment