Re: Problems with mkdir() and is_dir()



Juby wrote:

I'm creating a script for our website which will function as something
of a docment manager. The backend features an option to create a new
directory in the uploads subdirectory. The problem is, once I've used
mkdir() to create this file, when I later run is_dir() on the filename,
I get 'false'. Even worse, if I run is_file() on the new directories,
I get false as well. The same thing seems to be happening to files I
submit via the script, though that is less of a worry (I never actually
*need* to run this test). Here is a copy of a smaller script I threw
together trying to figure out what exactly was going on:

<?php

function getDirectoryList($root="(this is where the directory I'm
working in goes)"){

clearstatcache();

$dir = dir($root);

while($file = readdir($dir->handle)){
if(is_dir($file)){
echo "<br />directory:" . $file;
} elseif(is_file($file)){
echo "<br />file:" . $file;
} else {
echo "<br />dunno:" . $file;
}
}

}

getDirectoryList();

?>

Here's what I get:

directory:.
directory:..
dunno:delete.png
dunno:rename.png
dunno:view.png
directory:images
dunno:PDFs
dunno:somecrap

The last two, PDFs and somecrap, are folders created with mkdir(). The
.pngs are files uploaded via a PHP script. Is this some kind of fluke
with PHP, or is there anything I can do? Thank you all in advance for
your help.

Peace,
Juby


Hi Juby,

Where is the directory excactly?
How does the path look?
Is it some networkmapped directory, samba, etc?

Maybe you forgot to use \ before / ?

If you provide that info, maybe we can find the problem.

Regards,
Erwin Moller
.



Relevant Pages

  • Re: [PHP] Disabling the built-in POST handler
    ... I need to handle very large file uploads and push the data into a socket. ... again inside the script and pushing it into the socket is very inefficient ... Is there a way to completely disable the built-in POST form data handling ... of PHP and handle the data inside the script by reading php://input? ...
    (php.general)
  • Re: [PHP] Disabling the built-in POST handler
    ... I need to handle very large file uploads and push the data into a socket. ... Having php to write everything to a temporary file, then reading it ... again inside the script and pushing it into the socket is very inefficient ... of PHP and handle the data inside the script by reading php://input? ...
    (php.general)
  • Appending Date/Time Stamp to filename
    ... how do I append the datetimestamp to ... The files are processed using the PHP ... Following server-side PHP script receives and uploads the files: ...
    (microsoft.public.scripting.jscript)
  • Problems with mkdir() and is_dir()
    ... I'm creating a script for our website which will function as something ... The backend features an option to create a new ... The last two, PDFs and somecrap, are folders created with mkdir(). ... ..pngs are files uploaded via a PHP script. ...
    (comp.lang.php)
  • Re: [PHP] File Upload Security and chmod
    ... So I've been trying to figure out where php uploads files to temporarily ... security recommendations at face value but to give them some thought, ... much larger number of bytes are a valid image. ...
    (php.general)