问题
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