Programmatic file upload with jQuery-File-Upload

半世苍凉 提交于 2019-12-14 03:18:16

问题


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});

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

       var image = canvas.toDataURL();

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


回答1:


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!



来源:https://stackoverflow.com/questions/18210031/programmatic-file-upload-with-jquery-file-upload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!