使用jQuery-File-Upload进行程序化文件上传 [英] Programmatic file upload with jQuery-File-Upload

查看:79
本文介绍了使用jQuery-File-Upload进行程序化文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery-File-Upload插件上传图像.现在我从画布创建图像,并想使用相同的机制将该图像传输到服务器. 在jQuery-File-Upload文档中,我找到了以编程方式使用fileUpload组件的方法,但它希望将文件列表作为参数

I use jQuery-File-Upload plugin for uploading the images. now I create an image from canvas und would like to use the same mechanismus to transfer this image to the server. In jQuery-File-Upload documentation I found the way to use the fileUpload component programatically but it expects the list of files as parameters

     $('#fileupload').fileupload('send', {files: filesList});

在我的情况下,我的图像具有base64形式.

in my case I have the image in form of base64.

       var image = canvas.toDataURL();

如何使用fileUpload组件传输画布图像?

how can I use fileUpload component to transfer my canvas image?

推荐答案

只需将其作为POST数据发送,然后在服务器端从Base64对其进行解码并将其另存为png(我认为这是默认类型),但是该文件的mime类型将在base-64的开头!

Just send it as POST data, then on the server side decode it from Base64 and save it as a png ( which I think is the default type ) but the mime-type of the file will be at the start of the base-64!

这篇关于使用jQuery-File-Upload进行程序化文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆