>From reading your post, I believe you've successfully gotten the file upload
to work and now you're interested in using uploaded files (but with smaller
dimensions) on your webpage.  What you'll need to do is create a separate
file named resize.php which includes only the following code.

On your webpage you will call this file using the following:

<?
    print "<img src=resize.php title=\"small image\">";
?>

To see the error messages you'll need to substitute the above with:
<?
    print "<a href=resize.php>Click here</a>";
?>
Once you've deloused it you can revert to the img tag.

"resize.php" contains only the code below--with no blank line before the php
tag! "resize.php" will create a smaller image with a maximum dimension of
200 pixels.  Obviously, you can change this to some other method to get the
size you want.  Finally, the images generated aren't the best looking I've
seen, and if you've got a newer version of php than I've got access to, you
could change from imagecopyresized() to imagecopyresampled().

Hope this helps,
Hugh

<?php
    $picture="../photos/$userfile_name";  //or whatever you named your
uploaded files

    @$size=getimagesize($picture);
    $height=$size[1];
    $width=$size[0];


    $max=200;  // maximum dimension


    if ($height>$width)
     {
     $nheight=$max;
     $nwidth=$width/($height/$max);
     }
    else
     {
     $nwidth=$max;
     $nheight=$height/($width/$max);
     }

    $image=imagecreatefromjpeg($picture);
    $image1=imagecreate($nwidth,$nheight);

    imagecopyresized( $image1, $image,0,0, 0,0, $nwidth,
$nheight,$width,$height);

    header("content-type: image/jpeg");
    imagejpeg($image1);
    ImageDestroy($image);
    ImageDestroy($image1);
?>


----- Original Message -----
From: "Brian & Shannon Windsor" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, August 18, 2002 10:48 AM
Subject: [PHP] newbie php image importing problems


> Hello,
>
> I got some great help from this newsgroup a few days ago, and I'm 90%
> complete with my project, but I have one snag.  I'm building a web page
that
> allows a business to import pictures of their products and then display
them
> on their page along ith other information.
>
> My problem is getting in an image but displaying a thumbnail, and if
> clicked, the original image.  The client only wants to load one image.
I'm
> stuck at how to take the one image, copy it to the host server, and then
> display a thumbnail of the image.  I can make the thumbnail linkable to
the
> larger image, and I can display the original image on my home PC, but
that's
> all local.
>
> Please help.
>
> Thanks,
>
> Brian
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to