Nandini Posted November 21, 2008 Share Posted November 21, 2008 Hi i am using ubuntu. I want to create directory named as 'directory' using php. i am using following script. But not able to create directory. Can any one help me about the problem. My script is as follows $thisdir="/usr/local/netzgate/var/lib/netzgate"; $req_dir=$thisdir."/directory"; chmod($req_dir, 0755); $dir=mkdir($req_dir); if(!$dir) { echo "Directory not created..."; } else { echo "Directory created "; } It is displaying always as 'Directory not created'. I dont know whats the problem. Link to comment https://forums.phpfreaks.com/topic/133629-solved-mkdir-problem/ Share on other sites More sharing options...
ratcateme Posted November 21, 2008 Share Posted November 21, 2008 what is the permissions on /usr/local/netzgate/var/lib/netzgate ? i needs to be writable by 'apache'. Scott. Link to comment https://forums.phpfreaks.com/topic/133629-solved-mkdir-problem/#findComment-695206 Share on other sites More sharing options...
mtoynbee Posted November 21, 2008 Share Posted November 21, 2008 Should these be the other way round? chmod($req_dir, 0755); $dir=mkdir($req_dir); Should be $dir=mkdir($req_dir); chmod($req_dir, 0755); You can't chmod a directory that doesn't exist yet. Link to comment https://forums.phpfreaks.com/topic/133629-solved-mkdir-problem/#findComment-695210 Share on other sites More sharing options...
Nandini Posted November 21, 2008 Author Share Posted November 21, 2008 root@nani:/usr/local/netzgate/var/lib# ls -lrt total 4 drwxr-xr-x 9 root ng-data 4096 2008-11-20 23:41 netzgate root@nani:/usr/local/netzgate/var/lib# These are the permissions Link to comment https://forums.phpfreaks.com/topic/133629-solved-mkdir-problem/#findComment-695214 Share on other sites More sharing options...
Nandini Posted November 21, 2008 Author Share Posted November 21, 2008 Hi the problem was solved. I ts a permssions problem. First i have changed the permissions using 'chmod 0777 netzgate' on commandline. After that i have execute the script. Directory was created. Thanq very much for every help. Link to comment https://forums.phpfreaks.com/topic/133629-solved-mkdir-problem/#findComment-695217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.