not successful, but there is a certain reference/*** @param base64codes* Base64 encoding of images */function Sumitimagefile (base64codes) {//debuggerConsole.log (Convertbase64urltoblob (base64codes));var formData = new FormData (); The other parameters in the form are also submitted together, if you do not need to submit additional parameters can be directly formdata parameterless constructorsThe //convertbase64urltoblob function converts the Base64 encoding into a blobformdata.append ("ImageName", Convertbase64urltoblob (Base64codes)); The first parameter of the APPEND function is the parameter name of the background fetch data, and the same function as the Name property of the HTML tag inputtry{//Upload ("admin", "img", "Haode", formData);}catch (e) {Console.log ( e); alert ("The TMD is wrong again!" "); }//ajax Submit Form$.ajax ({url:localstorage.imurl+ '/plugins/zatp?cmd=upload ',type: "POST",Data:formdata,dataType: "JSON",Processdata:false,//Tell jquery not to process the data sentContenttype:false,//Tell jquery not to set Content-type request headersuccess:function (data) {console.log (data);alert ("hahaha"); },xhr:function () {//XMLHttpRequest object that uses Ajax directly in the jquery functionvar xhr = new XMLHttpRequest ();Xhr.upload.addEventListener ("Progress", function (evt) {if (evt.lengthcomputable) {var percentcomplete = Math.Round (evt.loaded * 100/evt.total);Console.log ("committing." +percentcomplete.tostring () + '% '); Print upload progress on the console }}, False);return XHR; } });}/*** Convert image URL data in base64 to BLOB* @param urldata* Base64 image data represented in URL mode */function Convertbase64urltoblob (urldata) { var Bytes=window.atob (Urldata.split (', ') [1]); Remove the header from the URL and convert it to byte//Handle exception, convert ASCII code less than 0 to greater than 0var ab = new ArrayBuffer (bytes.length);var ia = new Uint8array (AB);For (var i = 0; i < bytes.length; i++) {Ia[i] = bytes.charcodeat (i); }return new Blob ([ab], {type: ' Image/jpeg '});}
Base64 Transfer Image upload