<?php
$handle=opendir('.');
         echo "<select name=image_url>";
while (false!==($file = readdir($handle))) {

         // new code here
         $cExt = explode( ".", $file );

                                         // and here
     if ($file != "." && $file != ".." && ( strtolower( $cExt[1] ) == "jpg" ) {
         echo "<option ";
         echo "value=".$file.">";
         echo $file;
         echo "</option>\n\r";
         }
}
     echo "</select>";
closedir($handle);
?>



At 10:04 AM 3/8/01 -0800, Jerry Lake wrote:
>Ok, I am using this modified code from the
>manual. It works great, but how do I modify
>it further to only show .jpg files ?
>
><snip>
><?php
>$handle=opendir('.');
>         echo "<select name=image_url>";
>while (false!==($file = readdir($handle))) {
>     if ($file != "." && $file != "..") {
>         echo "<option ";
>         echo "value=".$file.">";
>         echo $file;
>         echo "</option>\n\r";
>         }
>}
>     echo "</select>";
>closedir($handle);
>?>
></snip
>
>Jerry Lake            - [EMAIL PROTECTED]
>Web Designer
>Europa Communications - http://www.europa.com
>Pacifier Online     - http://www.pacifier.com
>
>
>-----Original Message-----
>From: Sean R. Bright [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, March 07, 2001 4:50 PM
>To: 'Jerry Lake'; 'Henrik Hansen'; 'php general'
>Subject: RE: [PHP] populate select box with contents of a file?
>
>
>
>Take a look at dir() and readdir().  Those along with echo() should help you
>out.
>
>Sean
>
> > -----Original Message-----
> > From: Jerry Lake [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, March 07, 2001 7:40 PM
> > To: Henrik Hansen; php general
> > Subject: [PHP] populate select box with contents of a file?
> >
> >
> > I would like to be able to populate
> > the options of a select box with the
> > contents of my images directory online
> > so I can select the image I want to
> > go with the form I am filling out.
> > what functions do I need to look into
> > to figure this one out?
> >
> > Jerry Lake            - [EMAIL PROTECTED]
> > Web Designer
> > Europa Communications - http://www.europa.com
> > Pacifier Online           - http://www.pacifier.com
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail:
> > [EMAIL PROTECTED]
> >
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to