Page 1 of 1

JPEG Image Upload

Posted: Sat Nov 06, 2004 5:00 am
by dubs
Hi All

I've got an idea for a project that involves a user uploading a high res image to my server so we can artwork the files.

Could someone give me some advise on what is the best way to upload a large image max (5mb) . For example I would I stop the server from timing out during the upload and is there a way to create a thumbnail using the GD library etc

Cheers

Rich

Posted: Sat Nov 06, 2004 6:30 am
by m3mn0n
Well if the timeout time is set to something like 60 or 90, then you can set it to something higher for the duration of the scripts execution with [php_man]set_time_limit()[/php_man].

Other than that, it's just standard file uploading procedure.

Posted: Sat Nov 06, 2004 9:38 am
by kettle_drum
My file upload class in the code snippets section should cover you for most things.

Re: JPEG Image Upload

Posted: Sat Nov 06, 2004 4:52 pm
by hurdy gurdy
I believe the default value for PHP's upload max file size is 2 megs. You might have to change that, if you havent already.

Posted: Mon Nov 08, 2004 9:01 am
by dubs
Cheers all 8O

Posted: Mon Nov 08, 2004 12:57 pm
by emperor
To create a thumbnail from the uploaded JPEG try this:

Code: Select all

<?php
    $src = ImageCreateFromJPEG ($src_filename);

    $width = ImageSx ($src);
    $height = ImageSy ($src);
    $x = $desired_width;
    $y = $desired_height;

    $dst = ImageCreateTrueColor ($x, $y);
    ImageCopyResampled ($dst, $src, 0, 0, 0, 0, $x, $y, $width, $height);
    ImageJPEG ($dst, $dst_filename);    // or ImagePNG or whatever
    DestroyImage ($dst);
?>