• 0

PHP file and folders


Question

Is there anyway to determine is a string is a folder or a file name. I am making a directory listing page, but it is treating file like folders and getting errors.

DIRPAGE > if file > go to file url

DIRPAGE > if folder > open the folder ( i know how to use the folder thing )

Thanks

NERF

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

you could check to see if it has an extension or not, if it does its a file if it doesnt its a folder... you just wont be able to put dots in folder names

or you could ue expression matching...

dont know how to do this though :unsure:

http://php.net/scandir might be of some help..

btw, wrong forum?

Link to comment
Share on other sites

  • 0

I think this is a PHP question (hence wrong forum) but anyway...

Take a look at

http://uk2.php.net/manual/en/function.is-dir.php

and

http://uk2.php.net/manual/en/function.is-file.php

And remember, "folder" is Windows' childish name for what is formally known as a directory, so if you're searching Google or something, use directory rather than folder for better results.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.