【发布时间】:2013-03-11 06:06:45
【问题描述】:
在将图像上传到服务器之前,我正在尝试调整文件上传中的图像大小。我找到了一个decent plugin,它返回更新图像的 blob,但是我找不到如何将 blob 分配回上传使用的文件对象。
blob 看起来像:data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQAB.....
var file = e.target.files[0];
canvasResize(file, {
width: 300,
height: 0,
crop: false,
quality: 80,
//rotate: 90,
callback: function (data, width, height) {
// How to assign the data blob back to the file?
//$(file).attr('src', data);
// THEN submit with the smaller photo
$('#PhotoForm').ajaxSubmit(options);
}
});
谢谢!
【问题讨论】:
-
你有一个数据:方案 URI。您可以将其发布到服务器,然后将其解码回那里的二进制文件。
-
是的,您必须将 blob 作为文本发送回服务器,您将无法使用 blob 覆盖文件上传控件的值。
标签: javascript jquery image-processing html5-canvas