# Make Directory (mkdir) Problem

#1

Dear All:

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

The code as belows:

[php]
include(“list_var.php”);

$dbconnect;$db;

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

$sql_insertcategory .= “(”${cat}","${desc}")";$query = mysql_query($sql_insertcategory) ; if (!$query) {
die(‘Could not query:’ . mysql_error());
}
else
{

$dirbig .=$desc;
echo "$dirbig";$rtn=opendir("$dirbig"); if (!$rtn)
{
mkdir("$dirbig", 0755); }  } ?> [/php] 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: C:InetPubwwwroothomeleganceimagesbig33 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 [/quote] #2 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.

#3

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?

Thanks

#4

Sure, use the is_dir() function.

[php]
if (is_dir(’/home/path/to/directory))
{
Directory exists;
}
else
{
Directory doesnt exist;
}
[/php]