create directory in windows IIS
Posted: Mon Nov 06, 2006 6:55 am
i had this code running well when i'm using apache.. But i need to make it runable in IIS.. anybody help?
Code: Select all
<html>
<?php
include '../config.php';
include '../opendb.php';
?><head>
<title>(Add Product)</title>
<script language="javascript" event="onclick" for="btnAdd" runat="server">
if(document.frmAdd.txtBrand.value == "")
{alert("Please enter the brand name before adding..");
document.frmAdd.txtBrand.focus();
window.event.returnValue = false;
}
else if(document.frmAdd.txtLink.value == "")
{alert("Please enter the link before adding..");
document.frmAdd.txtLink.focus();
window.event.returnValue = false;
}
else if(document.frmAdd.txtFolder.value == "")
{alert("Please enter the Folder Name before adding..");
document.frmAdd.txtFolder.focus();
window.event.returnValue = false;
}else if(document.frmAdd.flLogo.value == "")
{
alert("Please select a file to upload as the Logo");
document.frmAdd.flLogo.focus();
window.event.returnValue = false;
}
</script>
</head>
<body>
<form name="frmAdd" method="post" action="<?php
echo $PHP_SELF;?>" enctype="multipart/form-data">
<table id="brand">
<tr>
<td colspan="2">Please enter the mandatory fields(<font color="#FF0000">*</font>)</td>
</tr>
<tr>
<td><font color="#FF0000">*</font>Brand name:</td>
<td><input type="text" value="" name="txtBrand"></td>
</tr>
<tr>
<td><font color="#FF0000">*</font>Link:</td>
<td><input type="text" value="" name="txtLink"></td>
</tr>
<tr>
<td><font color="#FF0000">*</font>Folder Name:</td>
<td><input type="text" value="" name="txtFolder"></td>
</tr>
<tr>
<td><font color="#FF0000">*</font>File to upload/store in database:</td>
<td> <input type="file" name="flLogo" size="40"></td>
</tr>
<tr><td colspan="2" align="right"><input type="submit" value="Add" name="btnAdd"></td></tr>
</table>
<?php
if(isset($_POST['btnAdd']))
{
$result=mkdir('../customer/'.$_POST['txtFolder']. 0777);
if(!$result){
print("Error: Couldn't create the directory!<BR>");
}else{
$uploadDir = '../customer/'.$_POST['txtFolder']."/";
$tmpName = $_FILES['flLogo']['tmp_name'];
$fileName = $_FILES['flLogo']['name'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file($tmpName, $filePath);
if(!$result){
print("Error uploading file");
exit;
}
if(!get_magic_quotes_gpc())
{
$fileName=addslashes($fileName);
$filePath=addslashes($filePath);
}
$query = "INSERT INTO tblBrand (strBrand,strLink,strImgLink,strFolderName ) "."VALUES ('".$_POST['txtBrand']."', '".$_POST['txtLink']."', '".$_POST['fileName']."', '".$_POST['txtFolder']."')";
mysql_query($query) or die('Error, query failed : '.mysql_error());
print("files updated");
}//result(creating dir)
}//btnAdd
function remove_directory($dir) {
if($handle = opendir("$dir")) {
while (false !== ($item = readdir($handle))) {
if ($item != "." && $item != "..") {
if (is_dir("$dir/$item")) {
remove_directory("$dir/$item");
} else {
unlink("$dir/$item");
echo " removing $dir/$item<br>\n";
}
}
}
closedir($handle);
rmdir($dir);
echo "removing $dir<br>\n";
}
}
if ($_GET['removeId'] != "" && $_GET['folderName'] !=""){
remove_directory("../customer/$folderName");
$query = "DELETE FROM tblBrand WHERE intId='$removeId';";
mysql_query($query) or die('Error, query failed : '.mysql_error());
print("Deleted");
}
include './brandContent.php';
include '../closedb.php';
?></form>
</body>
</html>