kool_samule Posted September 25, 2009 Share Posted September 25, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/175499-solved-mkdir-php-problem/ Share on other sites More sharing options...
Bricktop Posted September 25, 2009 Share Posted September 25, 2009 Hi kool_samule, 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. Quote Link to comment https://forums.phpfreaks.com/topic/175499-solved-mkdir-php-problem/#findComment-924756 Share on other sites More sharing options...
kool_samule Posted September 25, 2009 Author Share Posted September 25, 2009 Hi Bricktop, The mkdir works fine on the server (it creates it). The problem is when the directory already exists, and you try to create it again, you should see an error message, rather than an HTTP 500 message. Does that make sense? Quote Link to comment https://forums.phpfreaks.com/topic/175499-solved-mkdir-php-problem/#findComment-924766 Share on other sites More sharing options...
JonnoTheDev Posted September 25, 2009 Share Posted September 25, 2009 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); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/175499-solved-mkdir-php-problem/#findComment-924797 Share on other sites More sharing options...
kool_samule Posted September 25, 2009 Author Share Posted September 25, 2009 Nice one, sorted it! Cheers Quote Link to comment https://forums.phpfreaks.com/topic/175499-solved-mkdir-php-problem/#findComment-924818 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.