Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8880347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:08:58+00:00 2026-06-14T20:08:58+00:00

I am using Jcrop plugin to crop an image. I upload my photo with

  • 0

I am using Jcrop plugin to crop an image.

I upload my photo with a standard html form.
I show my last uploaded image with the following code:

 <img id="cropbox" src="<?php echo $target ?>" width="400" />

This looks like the following:enter image description here

My code for $target looks like this:

 <?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.";
     }
 ?> 

Now i can start selecting my area to crop:enter image description here

Now i want to save the selected crop area to a new jpg image using the following code:

<?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;
}

?>

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?

I have no idea.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:08:58+00:00Added an answer on June 14, 2026 at 8:08 pm

    You can put the path to file into $_SESSION when uploading the target. In your uploaded.php use this code (here you start the session with session_start() and put the formed target path to $_SESSION array):

     <?php 
     session_start();
     $target = "uploads/"; 
     $target = $target . basename( $_FILES['filename']['name']) ; 
     $_SESSION['target_path'] = $target;
    
     $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.";
     }
    ?> 
    

    In your crop.php:

    <?php
    session_start();
    if ($_SERVER['REQUEST_METHOD'] == 'POST')
    {
    $targ_w = 200;
    $targ_h = 400;
    $jpeg_quality = 90;
    
    $src = $_SESSION['target_path'];
    $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;
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using JCrop plugin to crop image, things are working good with following
I am trying to crop the image using JQuery Jcrop plugin with Java Stuff,
I'm using Jcrop to allow me to crop an uploaded image to be a
I have the following html code to upload an image: <input type=file name=before size=40>
I am using Jcrop to try crop and image and save it. http://deepliquid.com/content/Jcrop.html Out
I am using jcrop to crop the image in my php application.I am using
I am using Jquery form plugin. Popup is displayed with image uploading form. Image
I want to crop an image at the server side (I am using 'JCrop'
I'm trying to develop image crop using JQuery. I use ajax to upload the
I am using Jcrop jQuery to crop an image in an MVC3 application. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.