当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Uploading html5 canvas content using ajax on IOS

问题描述:

For a webbased application we want to be able to let people sign on an Ipad.running IOS

We use a canvas element to draw on and then upload it to an IBM I Service.running net.data

It works fine on chrome and firefox on a pc.

on an ipad in safari or chrome though the request seems to be empty.

I am searching for hours and don’t seem to be able to find out what is wrong with this code.

Does anybody Know Who I Could Fix this?

We are not using jquery by the way.

belowe is part of the code we use

thanks!

j.v.

GUI.Signature.dataURItoBlob = function(dataURI) {

var binary = atob(dataURI.split(',')[1]);;

var array = [];

var content = null;

for(var i = 0; i < binary.length; i++) {

array.push(binary.charCodeAt(i));

}

content= new Uint8Array(array);

return new Blob([content], {type: 'image/jpeg'});

};

GUI.Signature.send = function(){

if(!GUI.Signature.isEnabled()){return;}

var request = new XMLHttpRequest();

var dataURL = GUI.Signature.canvas.toDataURL('image/jpeg', 0.8);

var blob = GUI.Signature.dataURItoBlob(dataURL);

var fd = new FormData(GLOBAL.activeForm);

var fsUri = GLOBAL.activeForm.action.replace("MAIN","UPLOAD");

fd.append("signature", blob);

fd.append("blobName","signature" );

request.open('POST', fsUri, false);

request.send(fd);

};

网友答案:

the problem is indeed appending the Uint8Array tot the Blob object. Wrapping the Uint8Array in an ArrayBuffer solves the problem

it was answerd here

分享给朋友:
您可能感兴趣的文章:
随机阅读: