jQuery 文件上传插件 https://blueimp.net
jQuery File Upload Plugin https://blueimp.net
晚上好,
我想使用插件 jQuery 文件上传插件,但我遇到了问题。
我用的是base64图片,因为图片是经过裁剪工具来裁剪图片的。
如何通过.fileupload()上传和上传base64格式的图片
我需要 jquery / php 版本
我找不到解决方案,提前致谢
此致
来自他们的文档:https://github.com/blueimp/jQuery-File-Upload/wiki/API#programmatic-file-upload
$('#fileupload').fileupload('add', {files: filesList});
The second argument must be an object with an array (or array-like
list) of File or Blob objects as files property.
听起来好像很简单:
var blob = ... //you said in the comments you've got the blob...
var blob = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
$('#fileupload').fileupload('add', {files: [blob]})
现在,我还遇到了一些更复杂的代码 (source),这些代码表明类似这样的事情也是可能的:
$('#fileupload').fileupload({
autoUpload: true,
add: function (event, data) {
$.ajax({
url: "/upload",
type: 'POST',
dataType: 'json',
data: {doc: {title: data.files[0].name}},
async: false,
success: function(response) {
...
}
});
看起来很灵活。
晚上好, 我想使用插件 jQuery 文件上传插件,但我遇到了问题。 我用的是base64图片,因为图片是经过裁剪工具来裁剪图片的。 如何通过.fileupload()上传和上传base64格式的图片 我需要 jquery / php 版本
我找不到解决方案,提前致谢 此致
来自他们的文档:https://github.com/blueimp/jQuery-File-Upload/wiki/API#programmatic-file-upload
$('#fileupload').fileupload('add', {files: filesList});
The second argument must be an object with an array (or array-like list) of File or Blob objects as files property.
听起来好像很简单:
var blob = ... //you said in the comments you've got the blob...
var blob = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
$('#fileupload').fileupload('add', {files: [blob]})
现在,我还遇到了一些更复杂的代码 (source),这些代码表明类似这样的事情也是可能的:
$('#fileupload').fileupload({
autoUpload: true,
add: function (event, data) {
$.ajax({
url: "/upload",
type: 'POST',
dataType: 'json',
data: {doc: {title: data.files[0].name}},
async: false,
success: function(response) {
...
}
});
看起来很灵活。