无法附加文件名

时间:2012-02-10 18:28:46

标签: php

<?php

$con = mysql_connect("localhost","root","");
mysql_select_db("image", $con);

 if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
    $result = mysql_query("SELECT * FROM image ORDER BY file_name DESC LIMIT 1");

    $row = mysql_fetch_array($result);
    $src = '"'.$row['file_name'].'"';
    $targ_w = $targ_h = 300;
    $jpeg_quality = 90;

    $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/jpg');
    imagejpeg($dst_r,null,$jpeg_quality);

    exit;
}
?>

我可以通过echoing从数据库中检索file_name,但是我无法在此部分附加文件$img_r = imagecreatefromjpeg($src);这是导致错误的地方? 任何想法?

1 个答案:

答案 0 :(得分:2)

嗯...因为您无缘无故地在文件名中添加引号?

$src = '"'.$row['file_name'].'"';更改为$src = $row['filename'];