Tag: jquery fileupload rails

如何使用jquery文件上传调整客户端图像的大小

我通过jquery-fileupload-rails gem在Rails 3.2应用程序中使用blueimp jquery-file-upload 。 我正在尝试在上传之前在客户端调整图像大小,但是在遵循文档时遇到了问题。 我的代码如下。 目前上传工作完美,但图片未resize。 通过jquery-file-upload调整图像大小的正确语法是什么。 (基于此和本文档的coffeescript中显示了两种方法。对我来说都不适用。) #Coffeescript jQuery -> if $(“#new_asset”).length $(“#new_asset”).fileupload dataType: “script” add: (e, data) -> types = /(\.|\/)(jpe?g|png)$/i file = data.files[0] if types.test(file.type) || types.test(file.name) data.context = $(tmpl(“template-upload”, file)) $(‘#progress-container’).append(data.context) jqXHR = data.submit() $(“button.cancel”).click (e) -> jqXHR.abort() else alert(“#{file.name} is not a jpeg or png image file”) progress: […]