title: Upload Base64 to S3
body: <p>I'm trying to upload an image to S3 without using an input or html form.</p>
  
  <p>My desired process is as follows: merge two HTML canvases, convert to base64, download as image, send image via email, upload to S3. My current code is as below:</p>
  
  <pre><code>function convertImage() {
      var bottleCanvas = document.getElementById('bottleCanvas');
      var designCanvas = document.getElementById('editorCanvas');
      var bottleContext = bottleCanvas.getContext('2d');
  
      if($('.colourCanvas500').is(':visible')) {
          bottleContext.drawImage(designCanvas, 153, 250);
      }
      else if($('.colourCanvas600').is(':visible')) {
          bottleContext.drawImage(designCanvas, 155, 238);
      }
      else if($('.whiteCanvas500').is(':visible')) { 
          bottleContext.drawImage(designCanvas, 132, 235);
      }
      else if($('.whiteCanvas600').is(':visible')) {
          bottleContext.drawImage(designCanvas, 132, 235);
      }
  
      var data = bottleCanvas.toDataURL("image/png");
      var link = document.createElement('a');
      link.download = "bottle-design.png";
      var dataLink = bottleCanvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
      //document.write(dataLink);
      link.href = dataLink;
      link.click();
  
      $('#imageInput').val(data);
  
      $('form[name="bottleDetails"]').submit();
  }
  </code></pre>
  
  <p>I have the following code I'm using to upload a logo to S3 from file:</p>
  
  <pre><code>&lt;?php
  include('php/image_check.php');
  $msg='';
  if($_SERVER['REQUEST_METHOD'] == "POST")
  {
  
  $name = $_FILES['file']['name'];
  $size = $_FILES['file']['size'];
  $tmp = $_FILES['file']['tmp_name'];
  $ext = getExtension($name);
  
  if(strlen($name) &gt; 0)
  {
  
  if(in_array($ext,$valid_formats))
  {
  
  if($size&lt;(2048*2048))
  {
  include('php/s3_config.php');
  //Rename image name. 
  $actual_image_name = time().".".$ext;
  if($s3-&gt;putObjectFile($tmp, $bucket , $actual_image_name, S3::ACL_PUBLIC_READ) )
  {
  $s3file='http://'.$bucket.'.s3.amazonaws.com/'.$actual_image_name;
  
  session_start();
  $_SESSION['uploadedImage'] = $s3file;
  header('Location: builder.php');
  
  
  }
  else
  $msg = "S3 Upload Fail.";
  
  
  }
  else
  $msg = "Image size Max 2 MB";
  
  }
  else
  $msg = "Invalid file, please upload image file.";
  
  }
  else
  $msg = "Please select image file.";
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>How would I go about uploading my base64/canvas image to S3 using PHP without a form?</p>