Re: How to Detect File in a Specifc Directory on Window Env?
| From: | Michael Sweeney | Date: | Fri, 19 Jul 2002 16:03:34 +0000 |
| Subject: | Re: How to Detect File in a Specifc Directory on Window Env? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108535@lists.php.net to get a copy of this message | ||
Since you know the name of the file you're looking for, why not just use
file_exists()? http://www.php.net/manual/en/function.file-exists.php
// Build the filename from the form submission
$filename = "whatever.pdf";
$path = "path/to/files/relative/to/runtime/dir";
if(file_exists("$path/$filename")) {
return(1);
}
else {
return(0);
}
That should be faster than trying to read directory contents.
..mike..
On Fri, 2002-07-19 at 01:59, Jack wrote:
> Dear all
> I had a folder which contains a lot of pdf file, the name format of the pdf
> files are : xxxxx.dateformat.pdf (eg : abcdefg.20020718.pdf).
> Now i want to use the php script to detect what files it got in a specific
> folder.
> i want to make a user input form which will let user to input the date and
> then i will look for the pdf report from this specific folder base on the
> Date given!
>
> I think one of the quickest way is to ask php to check the filename from
> "Right to Left" which is the Date format!
>
> But i don't know which php function will perform this task (Check filename
> from Right to Left).
>
> If you have any other suggestion, pls help me!
>
>