Jump to content


Photo

folder and sub-folder creation error


  • Please log in to reply
4 replies to this topic

#1 jure_matjaz

jure_matjaz
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 28 October 2006 - 02:51 PM

Hello!

I have problem with sub folder creation. I have tried with mkdir and even with shell_exec. Can you help. Here is the code....

---first code----

<?php

mkdir("album", 0777);
chmod("album", 0777);
//i've added this because it didn't want to set permisions to 777
mkdir("album/1/", 0777);

if (file_exists("album/")) {
  echo "Mapa obstaja";
} else {
  echo "Mapa ne obstaja";
}
if (file_exists("album/1/")) {
  echo "<br>Podmapa obstaja";
} else {
  echo "<br>Podmapa ne obstaja";
}
?>

----end------

----second_code------
<?php

shell_exec('mkdir album');
chmod("album", 0777);
shell_exec('cd album/ ; mkdir 1');


if (file_exists("album/")) {
  echo "Mapa obstaja";
} else {
  echo "Mapa ne obstaja";
}
if (file_exists("album/1/")) {
  echo "<br>Podmapa obstaja";
} else {
  echo "<br>Podmapa ne obstaja";
}
?>


---end----


Thank you for your help! Jure

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 28 October 2006 - 03:20 PM

you may need to use umask(); and also check to see if open_basedir is set on the server - if it is you will only be able to get php to manipulate the files/folders within that floder.
follow me on twitter @PHPsycho

#3 jure_matjaz

jure_matjaz
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 28 October 2006 - 04:56 PM

Hello!

At first i want to thank you, for your interest in problem...

I've tried useing umask, but folder has permisions(777) even without umask, so i think this isn't a problem.
I contacted my server administrator, to disable open_basedir function. But i didn't get reply ... so i don't know jet, if there is a problem.

Thank you for your help! Jure

#4 jure_matjaz

jure_matjaz
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 28 October 2006 - 05:06 PM

Hello again.

Now i've tried to use script with disabled open_basedir function, and it didn't work.

I don't get it... i have one function on other page for uploading pictures and i use ...

. ...shell_exec('cd slike/ ; mkdir ' . $album . ' ');... function

and it's working fine.

If i wan't to create folder with shell_exec here, it doesn't work....

If you have any other ideas, please let me know.

Thank you for your help! Jure

#5 jure_matjaz

jure_matjaz
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 30 October 2006 - 08:09 AM

Hello! Please if anybody can try this on his server, so i figure it out, if there is problem in code or server...


--------folders.php----------


<?php

mkdir("folder1", 0777);
chmod("folder1", 0777);
//i've added this because it didn't want to set permisions to 777
mkdir("folder1/folder2/", 0777);

if (file_exists("folder1/")) {
  echo "Folder exists";
} else {
  echo "Folder doesn't exist";
}
if (file_exists("folder1/folder2/")) {
  echo "
Sub-folder exists";
} else {
  echo "
Sub-folder doesn't exist";
}
?>

----------end------------------

It should make folder1 and sub-folder folder2 in folder1

Thank you for your help! Jure




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users