Jump to content

Recommended Posts

I have a simple mkdir script, that creates a directory that contains 3 sub-fodlers, on my server.

 

The script works fine on my Apache server and if the directory exists, the error message is displayed.

 

However on my IIS, I get an HTTP error, I don't think that the script is getting to the "if" or "else" functions :

PHP Warning: mkdir() [function.mkdir]: File exists  in C:\Web\QT\admin\script.php on line 85

// URL
$url = "//Server/Folder1/Folder2/";

// Create It
$create = mkdir("$url");
mkdir("$url/Sub1");
mkdir("$url/Sub2");
mkdir("$url/Sub3");

if ($create) {
  $mess = $ref = $_SERVER['HTTP_REFERER']; header( 'refresh: 0; url='.$ref);;
  $query = sprintf("UPDATE tbl_freelancer SET freedir='y' WHERE freeid=%s", GetSQLValueString($colname_rsFreelance_Dir, "int"));
  $result = mysql_query($query, $conndb2) or die(mysql_error());
}
else {
  $mess = "<p>Directory could not be created.</p>";
}

 

Is there a way of getting this to work?

Link to comment
https://forums.phpfreaks.com/topic/175499-solved-mkdir-php-problem/
Share on other sites

It's probably a permissions issue, i.e. the server is not allowing you to create in that directory.  Try CHMODding the containing folder to 777.

No. There is simply no condition to state that if the directory already exists then do not create. Here:

<?php
$newDir = "/home/html/mynewdir";
// if the directory does not exist then create it
if(!is_dir($newDir)) {
mkdir($newDir);
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.