|  | Posted by Rik Wasmus on 09/15/07 02:30 
On Fri, 14 Sep 2007 23:42:46 +0200, Confused but working on it  =
 <PostInGroups@wherever.com> wrote:
 
 > On 2007-09-13 08:10:48 -0700, Captain Paralytic <paul_lautman@yahoo.co=
 m>  =
 
 > said:
 >
 >> On 12 Sep, 17:50, Confused but working on it
 >> <PostInGro...@wherever.com> wrote:
 >>> Just wanted to say thanks for the posts helping me make ths work. Ad=
 ded
 >>> a few comments and after the readdir used a pattern match to test fo=
 r
 >>> .jpg, and seems to work fine on my test setup. Maybe I should test f=
 or
 >>> gif, tiff, and png... Anyway, here's the code:
 >>> <?php
 >>> //Open images directory
 >>> $dir =3D opendir("images");
 >>> //read files in the dir
 >>> while (($file =3D readdir($dir)) !=3D=3D false)
 >>> //test to make sure jpg
 >>> if (eregi("\.jpg",$file))
 >>> {
 >>> echo "<img src=3D'images/$file' class=3D\"pad1em\">";
 
 Hmm, are you sure about the class name? I'd say that on a new layout wit=
 h  =
 
 the same HTML 'pad1em' could end up making very little sense. A golden  =
 
 rule of css is that a classname should reflect what something is, not ho=
 w  =
 
 it is _displayed. A more suitable name could be something like  =
 
 'imagepreview' or the like.
 
 >>> }
 >>> closedir($dir);
 >>> ?>
 >>>  For my next trick I'm going to change the above to read a thumbs di=
 r,
 >>> and make a link to a larger picture of the same name in images.
 >>> Shouldn't be too hard bt my last programming class was almost 20 yea=
 rs
 >>> ago. :) Hats off to everyone that does this for a living.
 >>>  Thanks again!
 >>  I think that your ereg might find files such as fred.jpgs.php
 >
 > Yo Captain! (ex-nick of mine)
 >
 > So that will never be found because fred and I, well, his wife will te=
 ll  =
 
 > you the whole story...
 >
 > Just like a million other peeps I take pictures. I load em up in my ma=
 c  =
 
 > in iPhoto, make an album with the corresponding name and don't include=
 =
 
 > shats that were crappy. Export to a dir called images, filezilla to my=
 =
 
 > site. Use my little code to display on a page. I tried iWeb to make  =
 
 > pages, gallery databases done in php, and holy cow way to complicated.=
 =
 
 > Just easier to manage everything in directories by some kind of topic.=
 
 >
 > So is there a way for your exampe to happen?
 
 Oh yeah.
 (Just make sure the file is a proper image directly after an upload.  =
 
 Examining extention or mime-type is no good. I'm quite happy to us  =
 
 getimagesize() for this purpose, as it would return false if it couldn't=
 =
 
 interpret a file as an image.)
 
 And to display only files _ending_ in jp(e)g, I'd use  =
 
 preg_match('/\.jpe?g$/i',$string);
 -- =
 
 Rik Wasmus
  Navigation: [Reply to this message] |