Try to search your question here, if you can't find : Ask Any Question Now ?

Ajax code in php and javascript regarding an image file

HomeCategory: stackoverflowAjax code in php and javascript regarding an image file
Avatarbhawya asked 3 months ago

I am trying to save image file through signature pad. I want the name of the file to be an element from my div. Which changes accordingly. Here is my code. It is saving the image but the filename is blank(.png).


        html2canvas([document.getElementById('sign-pad')], {
            onrendered: function (canvas) {
                var canvas_img_data = canvas.toDataURL('image/png');
                var img_data = canvas_img_data.replace(/^data:image/(png|jpg);base64,/, "");
                var p = document.getElementById('my_class').innerHtml;
                //ajax call to save image inside folder
                    url: 'save_sign.php',
                    data: [{ img_data:img_data, p:p}],
                    type: 'post',
                    dataType: 'json',
                    success: function (response) {


$result = array();
$imagedata = base64_decode($_POST['img_data']);
$filename = $_POST['p'];
//Location to where you want to created sign image
$file_name = './doc_signs/'.$filename.'.png';
$result['status'] = 1;
$result['file_name'] = $file_name;
echo json_encode($result);

1 Answers
Best Answer
Avatarnaveen answered 3 months ago
Your Answer

6 + 5 =

Popular Tags

WP Facebook Auto Publish Powered By :