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:
- <?php
- include('../includes/php_header.php');
- include('../includes/connect2db.php');
-
- $item_guid = $_GET["id"];
- ?>
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>New Item</title>
- <link href="../css/admin_style.css" rel="stylesheet">
- <!-- jQuery-->
- <script src="../jQueryAssets/jquery-1.11.2.js"></script>
- <script src="../jQueryAssets/jquery-ui.js"></script>
- <link rel="stylesheet" href="../jQueryAssets/croppie/croppie.css" />
- <script src="../jQueryAssets/croppie/croppie.js"></script>
-
- <!-- JQuery CSS -->
- <link href="../css/start/jquery-ui.css" rel="stylesheet">
- <link href="../css/start/jquery-ui-1.10.3.custom.css" rel="stylesheet">
-
- <script>
- $(function()
- {
- $("#btnSave, #btnCancel").button();
-
- $('#btnCancel').click(function() { window.location = 'index.php'; });
- });
- </script>
-
- </head>
- <body>
-
- <center>
-
- <br><br><br>
- <?php
- $mysql_query = $mysql_connection->prepare('CALL sp_get_item_details_by_item_guid(:param_item_guid)');
- $mysql_query->bindParam(':param_item_guid', $item_guid, PDO::PARAM_STR);
-
- $mysql_query->execute();
-
- while($mysql_row = $mysql_query->fetch())
- {
- $item_id = $mysql_row["item_id"];
- $item_name = $mysql_row["item_name"];
- }
- ?>
- <h1>Main Image</h1>
- <b><?php echo $item_name; ?></b><br><br><br><br>
-
- <form id="frmCakeBoutique" action="save_item_main_image.php" method="post">
-
- <input type="hidden" id="txtItemGUID" name="txtItemGUID" value="<?php echo $item_guid; ?>" />
- <input type="hidden" id="txtItemID" name="txtItemID" value="<?php echo $item_id; ?>" />
-
- <input type="file" id="txtImage" name="txtImage" value="Choose a file" />
-
- <br><br>
-
- <div class="upload-msg">
- Upload an Item image
- </div>
-
- <br><br>
-
- <div id="upload-demo"></div>
-
- <br><br>
- <button id="btnSave" type="submit" style="width: 100%;">Save</button>
-
- <br><br>
- <button id="btnCancel" type="button" style="width: 100%;">Cancel</button>
-
- </form>
-
- </center>
-
- <script type="text/javascript">
- $(document).ready(function()
- {
- $uploadCrop = $('#upload-demo').croppie({
- viewport: {
- width: 405,
- height: 311,
- type: 'square'
- },
- boundary: {
- width: 405,
- height: 311
- }
- });
-
- $('#upload-demo').croppie('bind', {
- url: 'http://lifewallpaperz.com/image.php?pic=/images/2015/cute-cat/cute-cat-01.jpg',
- points: [77,469,280,739]
- });
-
- function readURL(input) {
- if (input.files && input.files[0]) {
- var reader = new FileReader();
-
- reader.onload = function (e)
- {
- // $('#blah').attr('src', e.target.result);
-
- $('#upload-demo').croppie('bind', {
- url: e.target.result,
- points: [77,469,280,739]
- });
- }
-
- reader.readAsDataURL(input.files[0]);
- }
- }
-
- $("#txtImage").change(function(){
- readURL(this);
- });
- });
- </script>
- </body>
- </html>