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 8152585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:45:20+00:00 2026-06-06T15:45:20+00:00

I have read my code again and again, but I can’t figure out whats

  • 0

I have read my code again and again, but I can’t figure out whats is wrong..

script:

    <?
    require_once("../constant/constant.php");
    if($_POST['action'] == 'imgsave'){

    $admin = $_POST['admin'];
    $profile = $_POST['profile'];

    $sth = $conn->prepare("SELECT * FROM profiles WHERE profile_id = '".$profile."'");
    $sth->execute();
    $row = $sth->fetch(PDO::FETCH_ASSOC);

    $targ_w = 180;
    $targ_h = 120;

    $src = imagecreatefromjpeg('../uploads/'.$profile.'.jpg');

    $tmp = imagecreatetruecolor($targ_w, $targ_h);
    imagecopyresampled($tmp, $src, 0,0,$_POST['x'],$_POST['y'],$targ_w,$targ_h,$_POST['w'],$_POST['h']);

    //Grab new image
    ob_start();
    imagejpeg($tmp);
    $image = ob_get_contents();
    ob_end_clean();
    imagedestroy($tmp);
    imagedestroy($src);

    //Create temporary file and write to it
    $fp = tmpfile();
    fwrite($fp, $image);
    rewind($fp);

    //Upload new image
    $conn_id = ftp_connect('ftp.test.com');
    ftp_login($conn_id,'user','pass');
    ftp_fput($conn_id,'/profiles/'.$row['path'].'/preview2.jpg', $fp, FTP_BINARY);
    fclose($fp);

    }
    ?>

It is combined with the jCrop script and all I wanted is to modify the original script to post it to http://FTP..

    $src = imagecreatefromjpeg($folder.$filename);
    $tmp = imagecreatetruecolor($targ_w, $targ_h);
    imagecopyresampled($tmp, $src, 0,0,$_POST['x'],$_POST['y'],$targ_w,$targ_h,$_POST['w'],$_POST['h']);
    imagejpeg($tmp, $folder.'t_'.$filename,100);

    imagedestroy($tmp);
    imagedestroy($src);

As you can see, the original script is very simple.. and I think I got stuck in how advanced it became.. Can anybody see the solution, or maybe give me a hint about what else to do..

  • 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-06T15:45:22+00:00Added an answer on June 6, 2026 at 3:45 pm

    The script is working…! No problems!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have android.permission.READ_OWNER_DATA but I can't find any reliable code that would explain how
I have read many question about improving the performance of C++ and C code
i executed the following c code on my ubuntu machine...i have read about fcntl()'s
I have to read 100.000 rows from database, I use this code : List<elementClass>
In support of some legacy code, I have to read a text file and
I have some code to read from a pdf file. Is there a way
I have made a code that read data from flash Nand (without filesystem). fd
I have written to code to read and write to registry which is working
When I using the following code to read file: lines=file(data.txt).read().split(\n) I have the following
I have used an open source code from CodeProject to read email from incoming

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.