Jump to content

Archived

This topic is now archived and is closed to further replies.

jure_matjaz

folder and sub-folder creation error

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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------------------

[b]It should make folder1 and sub-folder folder2 in folder1[/b]

Thank you for your help! Jure

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.