fede1749
Posts: 5
Joined: Thu May 14, 2015 1:09 am

PHP mkdir Raspbian

Thu May 14, 2015 1:24 am

Hi,

I have installed Raspbian, PHP 5.4.39 and Apache 2

I have a script, where i want make directory with PHP.

My script:

Code: Select all

<?
if (!file_exists('content/' . $schedule[0]['id'])){
    mkdir('content/' . $schedule[0]['id'], 0777, true);
}
?>
But, i test this too:

Code: Select all

<?
mkdir('content/');
?>
I receive the error: PHP Warning: mkdir(): Permission denied in /var/www/sgc-client/apikey.php on Line ..

The permission of the webroot folder:
drwxrwxrwx 3 root root 4096 May 13 21:45 sgc-client

The permission of the file:
-rwxrwxrwx 1 root root 2822 May 13 22:14 apikey.php

The permissions of directory /www
drwxrwxrwx 3 root root 4096 Feb 16 12:34 www

What could be the problem ?

Thanks.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: PHP mkdir Raspbian

Thu May 14, 2015 2:32 am

You omitted the line number of the file causing the error message. The php script is trying to mkdir() to a directory where it does not have permissions. Where is that?
marcus
:ugeek:

fede1749
Posts: 5
Joined: Thu May 14, 2015 1:09 am

Re: PHP mkdir Raspbian

Thu May 14, 2015 2:57 am

Hi Marcus .

You are right.
I think I needed to leave to one of my folders.

Solved.

If I see that fails again will create a new topic .

Thank you.

User avatar
DougieLawson
Posts: 39302
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: PHP mkdir Raspbian

Thu May 14, 2015 10:30 pm

sudo chown -R www-data.www-data /var/www
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Other programming languages”