I need auto crop image from the center of photo in php. How can I do this? First I upload the orginal image size and than I want to crop it and save on a directory.
Here is my code:
<form name="photo" id="photo" method="post" action="photo_ac.php" enctype="multipart/form-data">
<div class="form-group">
<input type="file" id="photo_upload" name="photo_upload" class="form-control sa_file">
</div>
<div class="sn_warning">
<p>
By clicking 'Upload photo' you confirm that you have permission from the copyright holder.
<a href="#">Having problems uploading photos?</a>
</p>
</div>
<div class="save_cancl">
<button class="btn btn-primary sv_cn_btn" type="submit">Upload Photo</button>
</div>
</form>
Upload Code :
<?php
// IMAGE UPLOAD ///////////////////////
$folder = "gallery_photo/";
$extention = strrchr($_FILES['photo_upload']['name'], ".");
$new_name = time();
$photo_upload = $new_name.$extention;
$uploaddir = $folder . $photo_upload;
move_uploaded_file($_FILES['photo_upload']['tmp_name'], $uploaddir);
//////////////////////////////////////////////////
//$insert_action = mysqli_query($con,"INSERT INTO `gallery_photos` (`id`, `user_id`, `photo_upload`) VALUES (NULL, '$user_id', '$photo_upload')");
?>
I want to crop and upload it on $folder = "gallery_photo/thumbs"
and also want to insert at mysql database.