Reply
List all files in directory with 1_ at beginning?
Old 03-16-2006, 01:10 AM List all files in directory with 1_ at beginning?
Ickie's Avatar
Extreme Talker

Posts: 217
Location: Australia
How can I list all the files (images) inside a directory that start with 1_...
1_ is actually a user id, I've made it so each time a user uploads a image it adds #_ to the beginning of the image and stripes any other underscores.

PHP Code:
<?
ob_start
();
include(
"config.php");

$path "";

$dir_handle = @opendir($path) or die("Unable to open $path");

while (
$file readdir($dir_handle)) 
{
    if(
$file!="." && $file!="..")
    echo 
"<a href='view.php?image=$file'><img src='thumbs/$file'></a>";
}

closedir($dir_handle);

?>
This is what I'm using at the moment... but I would like it so that it would only show files with 1_ or whatever.

PHP Code:
substr($_GET['image'], 0strpos($_GET['image'], '_')); 
I'm using this on other pages to get the number in fornt of the image. Thanks to sitepoint.
Ickie is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Reply     « Reply to List all files in directory with 1_ at beginning?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12396 seconds with 12 queries