note 53146 rejected from function.mkdir by betz
| From: | betz@php.net | Date: | Sun, 05 Jun 2005 16:22:17 +0000 |
| Subject: | note 53146 rejected from function.mkdir by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-89956@lists.php.net to get a copy of this message | ||
Note Submitter: webmaster at mattssitemissouri dot com
----
This is a long one so bear with me...
I am setting up a hosting service on my new windows machine. I have Apache, since I made the mistake
of ordering Windows XP PRO instead of Windows Server 2003. However I have a version of Apache called
XAMPP. It came bundled with PHP AND MySQL so it caught my attention.
MY PROBLEM: I have a very advanced PHP "File Manager" program that can copy, move, and
delete files and folders. There is also a (semi-)working file uploader (Long Story). My real problem
is with the "New Directory" scripts. Notice there are no functions at all! The File
Manager script checks the type of the file or dir and prints a table cell with an image and the name
of the file or directory:
<?PHP
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != '..' && $file != '.') {
if (is_dir($file)) {
// write code for directories
}
else {
//write copy, move, delete
if(@substr ($file, - @strlen (".html")) === ".html") {
// write code for HTML file
}
else {
// write code for all other files
}
}
}
}
}
?>
This code works great except for the newly created directories from the following script show up as
files instead of directories.
<?PHP
$dir = $_REQUEST['dir'];
$username = $_REQUEST['username'];
$newdir = $_REQUEST['dirname'];
if ($newdir!=null) {
if (!is_dir($newdir)) {
if (mkdir($newdir, 0777)) {
echo "Directory <b>$newdir</b> succesfully created!\n";
}
else {
echo "Error: Directory <b>$newdir</b> Could Not Be Created!\n";
}
}
else {
echo "Error: Directory <b>$newdir</b> Already Exists!\n";
}
}
else {
echo "Error: You did not enter a directory name!\n";
}
?>
In Windows Explorer, the directory appears as a folder, but when I edit its properties, the
"Read-Only" atrribute has a square in it. WTF? Does it have anything to do with my
configuration? Anyone with knowledge, please help!