Make Directory (mkdir) Problem

Dear All:

I have a web page that will auto create a folder when a new item created.

The code as belows:



$cat = $_REQUEST[‘category’];
$desc = $_REQUEST[‘desccription’];

$sql_insertcategory .= “(”${cat}","${desc}")";
$query = mysql_query($sql_insertcategory) ;

if (!$query) {
die(‘Could not query:’ . mysql_error());

$dirbig .= $desc;
echo "$dirbig";


if (!$rtn)
	mkdir("$dirbig", 0755);



The $dirbig I set it to $dirbig = "C:\InetPub\wwwroot\homelegance\images\big\"; in list_var.php

I manage to create the holder when I access to the page on my own PC(host the pages). But when I try acces to the page through other PC. It will give me the belows messages:

Warning: opendir(C:InetPubwwwroothomeleganceimagesbig33): failed to open dir: Invalid argument in c:inetpubwwwrootact_addcategory.php on line 25

Warning: mkdir(C:InetPubwwwroothomeleganceimagesbig33): Permission denied in c:inetpubwwwrootact_addcategory.php on line 29

How should i resolve the above error, or how should i code so that the client browse know that, It should create the folder on server side. Not Locally.

Thank You for advices


I think the ‘Permission denied’ message is a clue for mkdir(). You need to have writeable permissions set for this to work. Do this by chmoding the directory to 777.

There is the chmod() function, but some servers will not allow this to be performed through PHP. It has to be done manually.

You are receving the opendir() error because it says its an invalid argument. Is your $dirbig variable correct?

Is $desc = $_REQUEST[‘desccription’]; correct? I notice the typo in description.

Thank a lot for the advices. I manage to create the folder now.

Other question is, is there any function I can use to check the give directory exist in the server or not?


Sure, use the is_dir() function.

if (is_dir(’/home/path/to/directory))
Directory exists;
Directory doesnt exist;

Sponsor our Newsletter | Privacy Policy | Terms of Service