Код: Выделить всё
html2canvas(image-container).then(function (canvas) {
canvas.toBlob(function (blob) {
jQuery.ajax({
url:"//domain.com/wp-admin/admin-ajax.php",
type: "POST",
data: {action: "addblobtodb", image: blob},
success: function(id) {
console.log("Succesfully inserted into DB: " + id);
}
});
Код: Выделить всё
function add_poster_to_db() {
global $wpdb;
$image = $_POST['image'];
ob_start();
// Insert een nieuwe rij aan de test_poster_images db
$wpdb->insert('test_images', array(
'image_data' => $image,
));
$db_id = $wpdb->insert_id;
wp_send_json( $db_id );
die();
}

Как вставить большой двоичный объект в таблицу Wordpress?
Подробнее здесь: https://stackoverflow.com/questions/782 ... tion-inser