I use jQuery file upload in my project since three months to upload and resize image files. Everything was working fine until last week. The plugin doesn't resize the images anymore (latest google chrome and latest firefox).
I'm using the same basic configuration on this page https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin
Does someone has the same issue and maybe a solution ?
Thanks
I couldn't get client side image resizing to work and I discovered it was because I had overridden the add method and didn't include code to do the image resizing that was in the original method. I'll post my solution in hopes that it helps save someone some frustration.
<form action="/path/to/uploadHandler" id="multiple-image-upload" enctype="multipart/form-data" method="post" accept-charset="utf-8">
<input name="files" multiple="multiple" id="files" type="file">
</form>
<div id="file-upload-progress">
<div id="upload-progress">
<div class="bar" style="width: 0%;"></div>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#multiple-image-upload').fileupload({
dataType: 'json',
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent),
process:[
{
action: 'load',
fileTypes: /^image\/(gif|jpeg|png)$/,
maxFileSize: 20000000 // 20MB
},
{
action: 'resize',
maxWidth: 1920,
maxHeight: 1200,
minWidth: 800,
minHeight: 600
},
{
action: 'save'
}
],
add: function (e, data) {
data.context = $('<p/>').text('Uploading '+data.files[0].name+'...').appendTo("#file-upload-progress");
var $this = $(this);
data.process(function () {
return $this.fileupload('process', data);
}).done(function() {
data.submit();
});
},
done: function (e, data) {
data.context.html('<img src="'+data.result.files[0].thumbnailUrl+'" alt="'+data.result.files[0].name+'" />');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#upload-progress .bar').css(
'width',
progress + '%'
).text(
progress + '%'
);
}
});
})();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With