Image upload with resizing and additional thumbnail creation

    Date: 05/02/06 (PHP Community)    Keywords: php

    Hi guys, since I'm a PHP novice I need some help with this script. I have a perfectly working script for uploading an image with resizing, *BUT* I need a script that takes the same image from the form a second time and creates a thumbnail from that. So the image would be uploaded twice - once as thumbnail and once as the original (resized). How exactly can that be done?

    Thank you so much in advance :=)


    This is the current script;

    if ($uploadfile != "") {

    $uploadedfile = $_FILES['uploadfile']['tmp_name'];


    $src = imagecreatefromjpeg($uploadedfile);


    list($width,$height)=getimagesize($uploadedfile);


    $newwidth = 500;

    $newheight = ($height/$width)*500;
    $tmp = imagecreatetruecolor($newwidth,$newheight);


    imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);


    $filename = "/www/dir/". $_FILES['uploadfile']['name'];
    imagejpeg($tmp,$filename,100);

    imagedestroy($src);
    imagedestroy($tmp);


    // for the db
    $foto = "dir/". $_FILES['uploadfile']['name'];
    }

    Source: http://community.livejournal.com/php/446151.html

« Using the IP address to... || Weird emails generated from... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home