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);

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

        }else{

Answers


Use

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

Need Your Help

Variables will not hold a value in a foreach loop

php codeigniter

I have a very odd problem with the following code. For some reason I can't get $id1 or $id2 to hold values unless it is placed outside the if and else...if statements. The variables simply will not

Running Google App Engine application on multiple customer domains

java google-app-engine subdomain multi-tenant domain-name

I want to allow my company’s customers to integrate our Google App Engine application into their domains. For example, let’s say one customer owns the domain coolcustomer.com and wants to make our...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.