我想在將圖片上傳到服務器之前調整文件上傳中的圖片大小。我發現decent plugin返回更新圖像的blob,但是我找不到如何將blob分配回上傳使用的文件對象。在上傳HTML文件之前調整圖片的大小5
團塊的樣子:數據:圖像/ 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);
}
});
謝謝!
您已獲取data:scheme URI。您可以將其發佈到服務器,然後將其解碼爲二進制文件。 – Quentin 2013-03-21 16:03:40
是的,你將不得不將blob發送回服務器作爲文本,你將無法用blob覆蓋文件上傳控制的值。 – Adrian 2013-03-21 16:29:56