Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-16-2007, 11:28 PM   PM User | #1
Peuplarchie
Regular Coder

 
Join Date: Feb 2006
Posts: 262
Thanks: 23
Thanked 1 Time in 1 Post
Peuplarchie is an unknown quantity at this point
Post Read dir and sub-dir and put image in dropdown box

Good day to you all,
I have searched , tried, many way but I can't figure how to make that piece of code look into all the sub-folder and take show all image file in a drop down box.

PHP Code:
<script language="JavaScript" type="text/javascript" >
function changePic(fe){
var opt_key = fe.selectedIndex;
var fileName = fe.options[opt_key].value;
document.noimage.src=fileName;
return true;
}
</script>
<select name="image" onchange="changePic(this);">
  <option>[Choisir une image]</option>
<?php
function PGL_ConfigList($dir)
{
    
$pattern="\.(jpg|jpeg|png|gif|bmp)$";
    
$files = array();
    if(
$open opendir($dir)) 
    {        
        while(
false !== ($file readdir($open)))
        {
            if(
eregi($pattern$file) && !is_dir($file))
            {
                
$files[] = $file;
            }        
        }
    }
    
closedir($open);

    return(
$files);
}
$dir "Upload/";
$list PGL_ConfigList($dir);
foreach(
$list AS $file)
{
    echo 
"<option value=\"Upload/$file\">$file</option>";
}
echo 
"</select>";
?>


Can somebody help me with this ?
I'm on php 4, on window 2003
Peuplarchie is offline   Reply With Quote
Old 07-17-2007, 09:25 AM   PM User | #2
NancyJ
Senior Coder

 
NancyJ's Avatar
 
Join Date: Feb 2005
Location: Bradford, UK
Posts: 3,162
Thanks: 19
Thanked 65 Times in 64 Posts
NancyJ will become famous soon enough
works fine for me - what is the problem? Are you getting an error of some sorts? Perhaps the problem is the directory that you're giving it.
__________________
http://www.hazelryan.co.uk
NancyJ is offline   Reply With Quote
Old 07-17-2007, 12:53 PM   PM User | #3
Peuplarchie
Regular Coder

 
Join Date: Feb 2006
Posts: 262
Thanks: 23
Thanked 1 Time in 1 Post
Peuplarchie is an unknown quantity at this point
Yes it's working fine, I need it to look into that same directory and his sub-directory to find all the images within the folder and his sub folder.
Peuplarchie is offline   Reply With Quote
Old 07-17-2007, 12:58 PM   PM User | #4
NancyJ
Senior Coder

 
NancyJ's Avatar
 
Join Date: Feb 2005
Location: Bradford, UK
Posts: 3,162
Thanks: 19
Thanked 65 Times in 64 Posts
NancyJ will become famous soon enough
I see, well this should be what you're looking for then
http://www.codingforums.com/showthread.php?t=71882
__________________
http://www.hazelryan.co.uk
NancyJ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:24 PM.


Advertisement
Log in to turn off these ads.