I am working on a custom t-shirt designer, within a Wordpress website. I'm using a Fabric.js (HTML canvas) to create the designs, and I've added WooCommerce to handle the checkout experience.
My problem is that I now need to somehow store the design as an image and tie it to the logged in user, so I can email it to the admin when the customer has checked out.
After some searching, I'm converting the canvas to dataURL in my javascript:
    dataURL = canvas.toDataURL("image/png");
    dataURL = dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
    $.post("image_save.php?data="+dataURL);
Then in my working dir (wp-content/themes/startit-child), I've created image_save.php to save the data to the user_meta, with the following code:
<?php
  global $current_user;
  $imageData = $_POST['data'];
  $imageData = base64_decode($imageData);
  update_user_meta( $current_user->ID, 'user_design', $_POST['$imageData']);  
?>
My POST request is failing, and receiving an net::ERR_CONNECTION_CLOSED error instead. (I suspect that I'm not pointing to my image_save.php correctly.
The full error looks like (shortened obviously);
https://mywebsite.com/design-page/image_save.php?data=iVBORw0KGScxzxZXC...= net::ERR_CONNECTION_CLOSED
I've wasted a lot of time trying to make this work. By this point, I'm open to any other potential solution, if any.
