santunu23 0 Newbie Poster

HI
i am trying to work with a html5 canvas for signature capture i got script and try to get the signature with ajax and php

function saveit()

{
var myDrawing=document.getElementById("newSignature");
var drawingString=myDrawing.ToDataUrl("image/png");
var postData="canvas="+drawingString;
var ajax=new XMLHttpRequest();
ajax.open("POST",'saveimage.php',true);
ajax.setRequestHeader('Content-Type','canvas/upload');
ajax.onreadystatechange=function()
{
if(ajax.readyState==4)
{alert("image saved");
}
ajax.send(postData);


}

and here is there is the saveimage.php

if (isset($GLOBALS['HTTP_RAW_POST_DATA']));
{
$rawImage=$GLOBALS['HTTP_RAW_POST_DATA'];
$removeHeaders=substr($rawImage,strpos($rawImage,",")+1);
$decode=base64_decode($removeHeaders);
$fopen=fopen('image/myImage.png','wb');
fwrite($fopen,$decode);
fclose($fopen);

}

else
{
echo "image can not be save";


}

using this i can't save the image.Any suggestion?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.