0

我一直在寻找解决这个问题的方法,直到我脸色发青。我一生都无法弄清楚为什么我的代码会返回全黑的图像。这是我的代码,有人可以提醒我应该在哪里寻找解决方案吗?

这是我的代码:

<?php
session_start();
$time = time();


$mem = $_SESSION['memid'];
//for the search image of the member
/**
 * Jcrop image cropping plugin for jQuery
 * Example cropping script
 * @copyright 2008-2009 Kelly Hallman
 * More info: http://deepliquid.com/content/Jcrop_Implementation_Theory.html
 */

// Desired folder structure
$structure = "./images/".$mem."/coverphoto/";
$search_img_path = $structure;

// To create the nested structure, the $recursive parameter 
// to mkdir() must be specified.

if (!file_exists($structure)) {
    mkdir($structure, 0777, true);
}

//if (!mkdir($structure, 0777, true)) {
//    die('Failed to create folders...');
//}

// ...

$original = $_SESSION["original_photo"];
$original = str_replace(" ", "%20", $original);

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
    $targ_w = 697;
    $targ_h = 408;
    $jpeg_quality = 90;

    $src = 'http://www.downtowndifferent.com/images/'.$mem.'/coverphoto/'.$original;
    $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,$structure.$mem.'_cover_photo_'.$time.'.jpg',$jpeg_quality);

    echo "The cropped photo was saved successfully.";

}

$coverimgpath = $mem.'_cover_photo_'.$time.'.jpg';

// If not a POST request, display page below:

$con = new mysqli('localhost', '*********', '*********', '*********'); 

$sql = "UPDATE member_page SET cover_img_path=? WHERE id=$mem";

$stmt = $con->prepare($sql);




var_dump($con->error);
$stmt->bind_param('s', $coverimgpath);
$stmt->execute();

if ($stmt->errno) {
  echo "FAILURE!!! " . $stmt->error();
}
else echo "<p>Image save successful!</p>";
$stmt->close();


?>
4

0 回答 0