Javascript / PHP:首先上传调整大小的图像,稍后上传大文件

I'm writing this design application where the user needs to upload images. It would be great if the client-side could upload thumbnails of the images first, allowing the user to get working before the real images have been uploaded. (They are only needed later, when exporting the design.)

I've looked briefly at a few packages which allow resizing, but they seem to upload the thumbnails and the images simultaneously, thus preventing the user from having the thumbnails available quickly.

Is it even possible to create a file upload so that resized images are uploaded first, then the real (fullsize) images?

Thanks, --Kjell

Try this:

$pathToThumbs = "path/to/thumbs";

$new_fname = "thumb-file-name";
$img = imagecreatefromjpeg( imagecreatefromjpeg($_FILES['uploaded_file']['tmp_name']) );

$width = imagesx( $img );
$height = imagesy( $img );
$thumbWidth = //someValue//;
$thumbHeight = //someValue//;
$new_height = floor($height * ($thumbWidth/$width));
$new_width = $thumbWidth;
$tmp_img = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width,$new_height, $width, $height );

move_uploaded_file( $tmp_img, "{$pathToThumbs}{$new_fname}" );