i have done a very simple painting app in canvas and now I have tried to figure out how to save the canvas (as image) and then upload it to a sql database (by using php and jquery and javascript). I have read many google pages about how to do it but i couldent really understand how to do it fully.
what i have come up with is that i think this is the code i need to make the canvas into a image.
var c=document.getElementById("myCanvas");
var myImage = c.toDataURL("image/png");
var image = document.getElementById("myCanvas");
image.src = myImage;
after this is done i have to send the image, i would like to use ajax to send the image to a new file called action. But the problem is that i dont know what i should have as data.
$.ajax({
type: "POST",
url: "action.php",
data: ??????????,
success: function(msg){
alert( "Data Saved: " + msg );
}
});
after i have send it to the action file i have to upload the image to the database. when i was searching i found something called blob and base64 but dident really understand how to use them.
As i can see it there is threee problems: 1. save the canvas into a image (i am not sure if my code is correct) 2. send the image via ajax to a action file (main problem is to know what data type to send) 3. from this file then send the image to the database, here i have no ide more then how to send standard stuff like CRUD (creat, read, update , delete). for example:
$sql = "INSERT INTO `div`(`ID`, `name`,)
VALUES( 'ID' ,' " . $_POST["name"] . "')";
but what i have read from the internet, is not nearly like this simple insert commando.
i am used to php javascript and jquery. So it would be simpeler for me to understand if i got it in a language i can read