RE: [PHP] Readdir




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
.pdf
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
.



Relevant Pages

  • Re: Cannot find page- cgiemail
    ... This depends on your host server supporting PHP files ... index files folder which has all of the other files in it. ... i have even used my host's file builder to upload each file seperately ... where do i find out what extension my mailer has? ...
    (microsoft.public.publisher.webdesign)
  • Re: Chmod
    ... Jerry Stuckle wrote: ... still be able to create the folder in PHP from a web page (so it's running as ... you to be able to upload files through the website. ...
    (comp.lang.php)
  • Re: Chmod
    ... still be able to create the folder in PHP from a web page (so it's running as ... JDS Computer Training Corp. ... you to be able to upload files through the website. ...
    (comp.lang.php)
  • Re: [PHP] Uploading into website directory for Php files
    ... How do I upload the include files into my Include ... upload the file into that include folder which is .:/include:/usr/ lib/php ... Sent from the PHP - General mailing list archive at Nabble.com. ... I'm not sure if they are chrooting something or if it's one of the base_dir things, but your web root is your root so you don't have access to /usr or anything else on the servers file system. ...
    (php.general)
  • Re: [PHP] Uploading into website directory for Php files
    ... How do I upload the include files into my ... I have my website on yahoo web hosting. ... upload the file into that include folder which is ... Then you can change the PHP include path via .htaccess or with ...
    (php.general)