0
votes

I have an problem and hope you can give me a hint for that:

I have an XAMPP running under OSx. My APP is in htdocs/app.

Inside /app there is a folder /scripts and there is my PHP File: app/scripts/file.php

Inside the /app folder there is a second folder /stuff that have 777 permissions.

from the script in app/scripts/file.php I want to create a folder in app/stuff

But I got permission denied when I try to create a folder like:

mkdir('../scripts/newfolder', 0777, true);

What do I have to do?

Note: When I test like this: mkdir('newfolder', 0777, true); Then it will work, but the new folder is under the wrong location: app/scripts/newfolder

3

3 Answers

0
votes

Give directory path as follows inside file.php.

mkdir('../stuff/newfolder', 0777, true);
0
votes

If I understand you correctly you want to make a folder in app/stuff from the app/scripts folder, but you are telling the computer to go back into the apps folder (..), then back into the scripts folder (../scripts/) and then to make the newfolder.

mkdir('../stuff/newfolder', 0777, true); 

should work then.

0
votes

Your trying to create a directory from a dynamic place. You should prefer to use DIR which is the absolute directory of the current file being processed.

so you would use

mkdir(__DIR__ . '/../stuff/newfolder', 0777, true);

assume this line from your question is correct

from the script in app/scripts/file.php I want to create a folder in app/stuff