Hacker
Hacker

Reputation: 7906

make directory inside html folder in apache server

i am trying to use

mkdir command. i am trying to create a folder under /var/www/html/some-appication . i get permission error. i need to create a folder in some-application folder . what steps do i need to take before doing it.

here is the command i am using

  $structure = '/var/www/html/'.$patientId;
                        if(!is_dir($structure))
                        {
                        if (!mkdir($structure, 0777, true))
                         {
                            die('Failed to create folders...');
                         }
                        }

Upvotes: 0

Views: 2792

Answers (2)

Ashay
Ashay

Reputation: 685

You can not directly create folder in root directory of a web-server by programming. As you don't have rights to do so. First you need to create folder in root directory & set the proper access rights (777) using FTP. then you can use following syntax for the creation of folder.

mkdir("/var/www/html/some-appication", 0777)

no need to use chmod function because it works on setting file permissions not folder.

Upvotes: 1

Bang Dao
Bang Dao

Reputation: 5102

Chmod 777 that folder. You can do that by using FTP chmod command or php chmod function
http://php.net/manual/en/function.chmod.php

Upvotes: 1

Related Questions