Image of the table images: link
Hi, I was doing a drawing game made with canvas and I have a "Upload" button with which I would like to upload the url of the image to the bd.
I have a function with which I can create a canvas url:
function pujar() {
var canvas = document.getElementById("canvas");
canvas.toBlob(function(blob) {
var novaImatge = document.createElement("img"),
url = URL.createObjectURL(blob);
alert(url);
novaImatge.onload = function() {
URL.revokeObjectURL(url);
};
novaImatge.src = url;
$('#pujar').remove();
});
My question comes here: Is there a way to call a php file inside the function to insert the url in the table? Right now my php file looks like this:
insert.php
include 'templates/database.inc.php';
//Per a afegir
include_once 'templates/magicquotes.inc.php';
try {
$sql = 'INSERT INTO imatges SET url = :"contingut"';
$s = $pdo->prepare($sql);
$s->execute();
}
catch (PDOException $e) {
$error = 'No se ha pogut insertar la imatge: ' . $e->getMessage();
include 'templates/error.html.php';
exit();
}
header('Location: .');
exit();