Upload Cropped Image to PHP

Upload Cropped Image to PHP

Hi,

I am using below plugin to crop image:


I wanted to know how to pass POST the image in order to process it in my PHP:

here is my code:

  1. <?php
  2.     include('../includes/php_header.php');
  3.     include('../includes/connect2db.php');
  4. $item_guid = $_GET["id"];
  5. ?>
  6. <!doctype html>
  7. <html>
  8. <head>
  9. <meta charset="utf-8">
  10. <title>New Item</title>
  11. <link href="../css/admin_style.css" rel="stylesheet">
  12. <!-- jQuery-->
  13. <script src="../jQueryAssets/jquery-1.11.2.js"></script>
  14. <script src="../jQueryAssets/jquery-ui.js"></script>
  15. <link rel="stylesheet" href="../jQueryAssets/croppie/croppie.css" />
  16. <script src="../jQueryAssets/croppie/croppie.js"></script>

  17. <!-- JQuery CSS -->
  18. <link href="../css/start/jquery-ui.css" rel="stylesheet">
  19. <link href="../css/start/jquery-ui-1.10.3.custom.css" rel="stylesheet">

  20. <script>
  21. $(function()
  22. {
  23. $("#btnSave, #btnCancel").button();
  24. $('#btnCancel').click(function() { window.location = 'index.php'; });
  25. });
  26. </script>

  27. </head>
  28. <body>

  29. <center>

  30. <br><br><br>
  31. <?php
  32. $mysql_query = $mysql_connection->prepare('CALL sp_get_item_details_by_item_guid(:param_item_guid)');
  33. $mysql_query->bindParam(':param_item_guid', $item_guid, PDO::PARAM_STR);
  34. $mysql_query->execute();

  35. while($mysql_row = $mysql_query->fetch())
  36. {
  37. $item_id = $mysql_row["item_id"];
  38. $item_name = $mysql_row["item_name"];
  39. }
  40. ?>
  41. <h1>Main Image</h1>
  42. <b><?php echo $item_name; ?></b><br><br><br><br>

  43. <form id="frmCakeBoutique" action="save_item_main_image.php" method="post">

  44. <input type="hidden" id="txtItemGUID" name="txtItemGUID" value="<?php echo $item_guid; ?>" />
  45. <input type="hidden" id="txtItemID" name="txtItemID" value="<?php echo $item_id; ?>" />

  46. <input type="file" id="txtImage" name="txtImage" value="Choose a file" />

  47. <br><br>

  48. <div class="upload-msg">
  49. Upload an Item image
  50. </div>

  51. <br><br>

  52. <div id="upload-demo"></div>

  53. <br><br>
  54. <button id="btnSave" type="submit" style="width: 100%;">Save</button>

  55. <br><br>
  56. <button id="btnCancel" type="button" style="width: 100%;">Cancel</button>

  57. </form>

  58. </center>

  59. <script type="text/javascript">
  60. $(document).ready(function()
  61. {
  62. $uploadCrop = $('#upload-demo').croppie({
  63.     viewport: {
  64.         width: 405,
  65.         height: 311,
  66.         type: 'square'
  67.     },
  68.     boundary: {
  69.         width: 405,
  70.         height: 311
  71.     }
  72. });
  73. $('#upload-demo').croppie('bind', {
  74.     url: 'http://lifewallpaperz.com/image.php?pic=/images/2015/cute-cat/cute-cat-01.jpg',
  75.     points: [77,469,280,739]
  76. });

  77. function readURL(input) {
  78.     if (input.files && input.files[0]) {
  79.         var reader = new FileReader();

  80.         reader.onload = function (e)
  81. {
  82.             // $('#blah').attr('src', e.target.result);

  83. $('#upload-demo').croppie('bind', {
  84. url: e.target.result,
  85. points: [77,469,280,739]
  86. });
  87.         }

  88.         reader.readAsDataURL(input.files[0]);
  89.     }
  90. }

  91. $("#txtImage").change(function(){
  92.     readURL(this);
  93. });
  94. });
  95. </script>
  96. </body>
  97. </html>