PHP Creating a file on the server via controller

I have the following code but it does not seem to be creating a folder at all.

Should I be using is_dir instead of file_exists?

        $location = $_SERVER['DOCUMENT_ROOT'].'/_assets/quote/uploads/';

        $folderName = $this->quote->getCompanyDetails()->companyName;
        $folderName = str_replace(" ", "_", $folderName);
        $folderName = strtolower($folderName);

            mkdir($location.$folderName, 0777);




if (!file_exists($dir) && !is_dir($dir)) {
    mkdir($location.$folderName, 0777);

is_dir function only detect if defined path is folder. Probably, you have not sufficient rights to create folder. Try to use

if (is_writable($dir)) {
echo "Path is writable";

to detect if really your path is writable.

It seems to be permission issue. Check do you have write permission in the directory where you are using mkdir.

Also use

echo $location.$folderName ;

to check it's happening at right place.

Hope this help.

Need Your Help

Heroku: encapsulate data access in an API

ruby-on-rails ruby database api heroku

I have a Heroku app with a PostgreSQL DB. Now I want to have a seperate process, possibly on a different machine, to access the DB. The suggestion on the Herkou site is actually what I wanted to do

Get a CompilationUnit from IBinding

java eclipse abstract-syntax-tree eclipse-jdt

I want to find a declaring node for a MethodInvocation: