Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to crop a selected image and save that cropped image to a folder using php
    primarykey
    data
    text
    <p>I am using Jcrop plugin to crop an image.</p> <p>I upload my photo with a standard html form. I show my last uploaded image with the following code:</p> <pre><code> &lt;img id="cropbox" src="&lt;?php echo $target ?&gt;" width="400" /&gt; </code></pre> <p>This looks like the following:<img src="https://i.stack.imgur.com/4GQYY.png" alt="enter image description here"></p> <p>My code for $target looks like this:</p> <pre><code> &lt;?php $target = "uploads/"; $target = $target . basename( $_FILES['filename']['name']) ; $ok=1; if(move_uploaded_file($_FILES['filename']['tmp_name'], $target)) { echo "De afbeelding *". basename( $_FILES['filename']['name']). "* is geupload naar de map 'uploads'"; } else { echo "Sorry, er is een probleem met het uploaden van de afbeelding."; } ?&gt; </code></pre> <p>Now i can start selecting my area to crop:<img src="https://i.stack.imgur.com/wyaUL.png" alt="enter image description here"></p> <p>Now i want to save the selected crop area to a new jpg image using the following code:</p> <pre><code>&lt;?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $targ_w = 200; $targ_h = 400; $jpeg_quality = 90; $src = ''; $img_r = imagecreatefromjpeg($src); $dst_r = ImageCreateTrueColor( $targ_w, $targ_h ); imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'], $targ_w,$targ_h,$_POST['w'],$_POST['h']); header('Content-type: image/jpeg'); imagejpeg($dst_r,NULL,$jpeg_quality); exit; } ?&gt; </code></pre> <p>My question is now, how do i use that $target Source i used to show the image i just uploaded in that php code above?</p> <p>I have no idea.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload