On 11/28/07, Chris <dmagick@xxxxxxxxx> wrote: > > > > In my solution, I use two scripts. One for showing the image true size > > and another for generating a thumbnail -- I may be wrong, but I think > > it's better to generate a thumbnail as needed on the fly than it is to > > store both images (large and thumbnail) in the dB. > > Cache it on the filesystem even if it's for a short time (of course if > the image is updated elsewhere the cache needs to be cleared as well..). > > > <?php > > $file = '/path/to/cache/file.jpg'; > if (file_exists($file)) { > if (filemtime($file) > strtotime('-30 minutes')) { > $fp = fopen($file, 'rb'); > fpassthru($fp); > exit; > } > > // the file is older than 30 minutes, kill it and start again. > unlink($file); > } > > // continue creating your thumbnail. > > $fp = fopen('/path/to/cache/' . $filename, 'wb'); > fputs($fp, $imagecontents); > fclose($fp); > > // display image > > -- Thanks for all the suggestions, guys. I was really trying to understand, through extending it, the code from the reference ( http://www.wellho.net/solutions/php-example-php-form-image-upload-store-in-mysql-database-retreive.html ). David