将图像保存到php中的文件夹

时间:2013-09-26 10:50:33

标签: php

我尝试了什么:

   $url = str_replace(' ', '%20', trim($url));
    $percent = 1.0; 
    $imagethumbsize = 200;
    header('Content-type: image/jpeg');

    list($width, $height) = getimagesize($url);
    $new_width = $width * $percent;
    $new_height = $height * $percent;


    $image_p = imagecreatetruecolor($imagethumbsize , $imagethumbsize);  
    $image = imagecreatefromjpeg($url);

    imagecopyresampled($image_p, $image, -($new_width/2) + ($imagethumbsize/2), -($new_height/2) + ($imagethumbsize/2), 0, 0, $new_width , $new_width , $width, $height);
    $hel=imagejpeg($image_p,"E:".DS."xampp".DS."htdocs".DS."opg-uat".DS."img".DS."c".DS , 100);

我得到的错误:“此图片无法保存,因为它包含错误” 有人帮忙。

2 个答案:

答案 0 :(得分:1)

删除

if($hel)
    echo 'Image saved';

来自您的代码。这是一张图片,但你正在写文字内容。

答案 1 :(得分:0)

尝试登录error.log或将其放在php文件的顶部:

error_reporting(E_ALL); ini_set('display_errors', '1');

它会显示所有错误。