Hello once again,

I created a script which creates a directory and lists the contents of that directory, in order for people to download stuff.

But the problem is, when the user clicks on 'back', the script cannot create the directory again, because it exists!

Anyway to bypass this?

Thanx once again...

thefisherman

    if( !is_dir('the_dir') )
    {
         mkdir('the_dir', 0777);
    }

      Why would you want to use file_exists() to check if a dir exists? What I do is to use is_dir() to check a dir and is_file() to check if a file exists.

        Why would you want to use file_exists() to check if a dir exists?

        Because if u take 2 seconds to look on php.net, its not just limited to files :rolleyes:

          Originally posted by DoD
          Because if u take 2 seconds to look on php.net, its not just limited to files :rolleyes:

          Hey! Atleast someone used the link I spent that extra time making!

          way to go! 😃

            I looked at the manual page before but I just couldn't see the little line where it said 'file_exists -- Checks whether a file or directory exists'.. :o 😉

              Of course, a directory is a file....

              But you'd use file_exists() because there might be a file (of any type) with the same name as the desired directory. And that could cause grief.

                Write a Reply...