我使用 plupload 和 php 类来调整大小http://www.verot.net/php_class_upload_docs.htm
一切顺利,但是当我上传只有 250kb 的 4000x2000 像素的大文件时,上传失败。调整大小的类有它的最大宽度和高度,但它设置为 NULL,所以它不检查它是否导致取消上传。
我在 AJAX 处理程序中的代码是这样的。
$foo = new Upload($_FILES['file']);
if ($foo->uploaded)
{
$new_name = functions::getRandomString(16);
$foo->file_new_name_body = 'b_' . $new_name;
if ($foo->image_src_x > 800 or $foo->image_src_y > 600)
{
$foo->image_resize = true;
$foo->image_ratio = true;
$foo->image_y = 600;
$foo->image_x = 800;
}
$foo->image_convert = 'png';
$foo->Process($upload_path);
if ($foo->processed)
{
//echo 'image renamed "foo" copied';
}
else
{
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Chyba prejmenovani."}, "id" : "id"}');
}
和 jQuery
$("#uploader").pluploadQueue({
// General settings
runtimes : 'html5,html4',
url : '/core/ajax/ajax_upload.php',
max_file_size : '10mb',
chunk_size : '5mb',
unique_names : true,
/*
resize : {width : 320, height : 240, quality : 90},
*/
// Specify what files to browse for
filters : [
{
title : "Image files",
extensions : "jpg,jpeg,gif,png"
}]
});
以及此具体文件上传会话的 JSON 响应
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,