dpx49470 2018-10-17 02:24
浏览 202

PHP 7 Imagick writeimage()路径问题

I'm trying to create a simple thumbnail image and upload to server using imagick. The image is being selected via a form and I am able to get the thumb created via Imagick, however it is not saving to the right location.

When I use the below code, the image saves to the same directory as the page the code is on and includes the file path within the image name. For example "\images\myuploaded.jpg" as the file name.

if($_SERVER['REQUEST_METHOD'] == 'POST'){
    $errors = array();
    if(preg_match("!image!", $_FILES['image']['type'])){
        $image = $_FILES['image']['tmp_name'];
        $imagethumb = new Imagick("$image");
        $imagethumb->setImageFormat("jpg");
        $imagethumb->thumbnailImage(100, 0);
        $imgpath = "\images\\".$_FILES['image']['name'];
        $imagethumb->writeImage($imgpath);
        $_SESSION['message']=$image;
    }else{
        $errors['image'] = "You must select a .png, .jpg, or .gif images file.";
        $_SESSION['message']=$errors['image'];
    }

}

Thanks for any help.

_t

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大