1

I can convert javascript functions to php to use it on server side through:

in JS:

$("#containerphp").load("save.php", {firstValueContainer:firstValue, secValueContainer:secValue});

in php (save.php):

$firstVal = $_REQUEST['firstValueContainer'];
$secVal = $_REQUEST['secValueContainer'];

It works fine but now I need to send a image variable (var image = canvas.toDataURL("image/png");) from javascript to php. I saw that the following code works to send it but in a form (without JS):

$_FILES['name']['tmp_name'];

Anybody knows how can I convert my image from JS to php in this context?

Thank you all.

user3822492
  • 145
  • 1
  • 11

1 Answers1

0

You can use the following

var image = canvas.toDataURL("image/png");

and send it to php

$_FILE can not be used here because $_FILE is An associative array of items uploaded to the current script via the HTTP POST method.

convert javascript functions to php to use it on server side through:

$("#containerphp").load("save.php", {firstValueContainer:firstValue, secValueContainer:secValue, imageValue: image});
Lucky
  • 575
  • 3
  • 18