upload images

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Darren

    upload images

    Hi,

    I am not an experienced PHP programmer and have look on the net for
    what I want to do.

    I'd like to allow the user on my website to upload two images one is to
    be turned into a thumbnail and one is to be turned into something of
    around 500 x 300, one stored in a thumbnail folder and one stored in an
    image folder.

    I can do it individually from different pages but not from the same
    form.

    Could someone point me in the direction of a script that does something
    like what I am after.

    Many thanks
    Darren

  • f.amann@rona.at

    #2
    Re: upload images

    Hi Darren,

    why do you need two forms??

    you just need one form with one <INPUT TYPE='file' NAME='upfile'.. .
    (the user selects his image with this input field)
    then post the form....
    after it you get your file with $_FILES[ upfile ]...


    then process $_FILES[ upfile ][ tmp_name ]:

    for your main graphic create a new image with: $bigImage =
    imagecreate($ne wWidth, $newHeight);
    in your case $newWidth must be 500; $newHeight = 300

    $origImage = imagecreatefrom *( $_FILES[ upfile ][ tmp_name] );
    Notice: * depends on filetype: e.g. jpg, gif, png --> have a look on
    php.net: imagecreatefrom jpeg

    to get the original height and width you need the getimagesize command:
    $infos = getimagesize($_ FILES[ upfile ][ tmp_name ]);
    $origWidth = $infos[0];
    $origHeight = $infos[1];

    imagecopyresamp led($bigImage, $origImage, 0, 0, 0, 0, $newWidth,
    $newHeight, $origWidth, $origHeight);
    image*($bigImag e,"/image/filename.*");
    Notice: * depends on filetype: e.g. jpg, gif, png --> have a look on
    php.net: e.g. imagegif

    just do the same for your thumbs (you just want a smaller
    $newWith/$newHeight):
    imagecopyresamp led($thumbImage , $origImage, 0, 0, 0, 0, $newWidth,
    $newHeight, $origWidth, $origHeight);
    image*($thumbIm age,"/tmb/filename.*");

    regards
    flo

    Comment

    • Darren

      #3
      Re: upload images

      Thanks Flo,

      Comment

      • Kevin D.

        #4
        Re: upload images

        "Darren" <groups@darrenl udlam.plus.com> wrote in message
        news:1139506262 .158500.231860@ g14g2000cwa.goo glegroups.com.. .[color=blue]
        > Hi,
        >
        > I am not an experienced PHP programmer and have look on the net for
        > what I want to do.
        >
        > I'd like to allow the user on my website to upload two images one is to
        > be turned into a thumbnail and one is to be turned into something of
        > around 500 x 300, one stored in a thumbnail folder and one stored in an
        > image folder.
        >
        > I can do it individually from different pages but not from the same
        > form.
        >
        > Could someone point me in the direction of a script that does something
        > like what I am after.
        >
        > Many thanks
        > Darren
        >[/color]

        check out this php class:
        ThumbNail class to resize images. By Vagharshak Tozalakyan. Modified to work with URL. tnimg.class.php This package implements an image gallery that uses a GMail account to store the images. This package is inspired in GImage, a PHP script available on the Web for a similar purpose. This class makes use of the libgmailer class to access your Gmail account. There is a libgmailer subclass to...


        you'll need to register to download it, but it's a great toolset for working
        with images (resizing, copying, etc.)

        - kevin


        Comment

        Working...