【问题标题】:Warning: getimagesize(image.jpg) [ ]: failed to open stream: no such file or directory警告:getimagesize(image.jpg) [ ]:打开流失败:没有这样的文件或目录
【发布时间】:2015-03-16 03:45:25
【问题描述】:

我在裁剪图像时遇到问题,但是当我在某些代码更改为裁剪之前用于调整图像大小时,此源工作正常。

这是作物的来源:

$filenames1 = stripslashes($_FILES['txtfile1']['name']);
$exts1 = substr($images1, strrpos($images1, '.')+1);
$idimgs = md5(uniqid() . time() . $filenames1) . "-1." . $exts1;
$target_files1 = $target_dir . basename($idimgs);

    list($width, $height) = getimagesize($filenames1);

    $realImages             = imagecreatefromjpeg($_FILES['txtfile1']['tmp_name']);

    if ($width > $height) {
    $y = 0;
    $x = ($width - $height) / 2;
    $smallestSide = $height;
    } else {
    $x = 0;
    $y = ($height - $width) / 2;
    $smallestSide = $width;
    }

    $thumbSize     = 200;

    $thumbImage = imagecreatetruecolor($thumbSize, $thumbSize);
    imagecopyresampled($thumbImage, $realImages, 0,0,$x,$y, $thumbSize, $thumbSize, $smallestSide, $smallestSide);

    imagejpeg($thumbImage,$target_dir.$idimgs);

    imagedestroy($realImages);
    imagedestroy($thumbImage);

如何解决这个问题?

【问题讨论】:

    标签: php upload resize-image


    【解决方案1】:

    php 不能直接从客户端系统访问文件。在这里您尝试访问$_FILES['txtfile1']['name'] 而不是尝试getimagesize($_FILES['txtfile1']['tmp_name'])

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-01
      • 1970-01-01
      • 2012-07-07
      • 1970-01-01
      • 2013-10-23
      • 2013-01-24
      • 2018-12-01
      • 1970-01-01
      相关资源
      最近更新 更多