RE: [PHP] Readdir
- From: Vincent.dupont@xxxxxxx ("Vincent DUPONT")
- Date: Tue, 28 Nov 2006 12:32:13 +0100
yes, glob works well.
here is an example to get pictures inside a folder ($path)
foreach(glob($path."/*/{*.gif,*.jpg,*.JPG,*.jpeg,*.JPEG,*.png}", GLOB_BRACE) as $filename){
$pics[]=$filename;
}
vincent
-----Original Message-----
From: Jochem Maas [mailto:jochem@xxxxxxxxxxxxx]
Sent: Tue 28/11/2006 10:59
To: Tom Chubb
Cc: [php] PHP General List
Subject: Re: [PHP] Readdir
Tom Chubb wrote:
What would be the best way to retrieve a list of files from an upload
folder that are called "id" where the extension could be .doc .txt or
For example, I have a folder where people can upload a document and
the document is renamed as their user id. They can upload a PDF, DOC
or TXT file. They may wish to upload one of each. I am using
file_exists for each case, but is there an easier/tidier way of doing
it?
Thanks in advance,
Tom
try the glob() function, something like:
$id = getUserId();
foreach (glob("/path/to/user/files/$id.*") as $file) {
echo $file,"<br />";
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
.
- References:
- Readdir
- From: "Tom Chubb"
- Re: [PHP] Readdir
- From: Jochem Maas
- Readdir
- Prev by Date: CLI script & exec() - how to control what gets dumped on the screen.
- Next by Date: RE: [PHP] CLI script & exec() - how to control what gets dumped on the screen.
- Previous by thread: Re: [PHP] Readdir
- Next by thread: Re: [PHP] Readdir
- Index(es):
Relevant Pages
|