0

コードを何度も読み直しましたが、何が間違っているのかわかりません..

脚本:

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

    }
    ?>

これは jCrop スクリプトと組み合わされており、元のスクリプトを変更して 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);

ご覧のとおり、元のスクリプトは非常に単純です..そして、私はそれがどれほど高度になったかに行き詰まったと思います..誰か解決策を見ることができますか、それとも他に何をすべきかについてのヒントを教えてください..

4

1 に答える 1

0

スクリプトは機能しています...!問題はありません!

于 2012-06-28T10:49:22.793 に答える