mkdir(folder_name) with 755 permission in php

I have my web application hosted in /var/www folder. I am creating a folder from one of the PHP scripts of the web application. The default permission of the created folder is drwx------, i.e. 700. But I want that folder to have at least 755 permission.

Up to now I tried: mkdir($path, 0755) and chmod($path, 0755) PHP functions but without any success.

Does anybody know how to solve my problem please?

Millions of thanks beforehand.


Have you tried changing the umask ?

Have a look here:

The easiest way it to:

$oldmask = umask(0);
chmod($path, 0755);

Since you have default permission of 700, which means the parent directory (the directory in which you are trying to create the folder) do not have rw permission for group owner or other users. Most often the running demon(httpd) is not the owner of the parent folder and hence cannot modify the directory.

In simple terms, the php script do not have access to modify or add new directory. You need to change the permission of the parent folder to at least drwxrw-rw- (or 0755).

Use ssh, cpanel or ftp client to do this. If you do it using php script you will end with the same problem again, as parent of parent will have again 0700. ;)

Need Your Help

Mars Exploration Rover Programming Language

java embedded

I have read that Java was used extensively for the MER project (i.e. Spirit and Opportunity - those little robots scurrying around Mars).

Display:inline-block not allocating the space properly

html css

I am using five div in my footer content with equal dividing space. But it is going to the next line instead of showing in one line. Check my fiddle here

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.