Author Topic: [SOLVED] mkdir problem  (Read 264 times)

0 Members and 1 Guest are viewing this topic.

Offline NandiniTopic starter

  • Enthusiast
  • Posts: 158
  • Gender: Female
    • View Profile
[SOLVED] mkdir problem
« on: November 21, 2008, 04:04:49 AM »
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.

Offline ratcateme

  • Devotee
  • Posts: 1,207
  • Gender: Male
    • View Profile
Re: mkdir problem
« Reply #1 on: November 21, 2008, 04:07:27 AM »
what is the permissions on /usr/local/netzgate/var/lib/netzgate ?
i needs to be writable by 'apache'.

Scott.

Offline mtoynbee

  • Enthusiast
  • Posts: 135
    • View Profile
Re: mkdir problem
« Reply #2 on: November 21, 2008, 04:09:59 AM »
Should these be the other way round?

Code: [Select]
chmod($req_dir, 0755);
$dir=mkdir($req_dir);

Should be

Code: [Select]
$dir=mkdir($req_dir);
chmod($req_dir, 0755);

You can't chmod a directory that doesn't exist yet.

Offline NandiniTopic starter

  • Enthusiast
  • Posts: 158
  • Gender: Female
    • View Profile
Re: mkdir problem
« Reply #3 on: November 21, 2008, 04:19:11 AM »
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

Offline NandiniTopic starter

  • Enthusiast
  • Posts: 158
  • Gender: Female
    • View Profile
Re: mkdir problem
« Reply #4 on: November 21, 2008, 04:23:35 AM »
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.