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

Packaging a .NET Application So It Will Run On A Computer Without .NET

c# .net redistributable

I have been recently trying to deploy a C# application on a computer that does not have .NET installed.

Table borders don't display properly when converted from HTML page into MS Word 2003

html css ms-word html-table

I've got a bit of a complicated set up. I specialise in XSLT which I write for 3rd party system. All CSS looks fine in the browser. Now that system provides a button that converts my generated HTML...