Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AbstractDecoder.php第302行中的NotReadableException:图像源不可读_Php_Mysql_Laravel - Fatal编程技术网

AbstractDecoder.php第302行中的NotReadableException:图像源不可读

AbstractDecoder.php第302行中的NotReadableException:图像源不可读,php,mysql,laravel,Php,Mysql,Laravel,我试图按照有关插入图像并调整其大小的教程进行操作,但我遇到了一个显示图像源不可读的问题 我正在使用PHP、Laravel5框架和mysql。当我运行代码时,我会在Image::make 这是我的控制器代码: use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Requests\FoodRequest; use App\Http\Controllers\Controller; use App\Photo; use Im

我试图按照有关插入图像并调整其大小的教程进行操作,但我遇到了一个显示图像源不可读的问题

我正在使用PHP、Laravel5框架和mysql。当我运行代码时,我会在
Image::make

这是我的控制器代码:

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Requests\FoodRequest;
use App\Http\Controllers\Controller;
use App\Photo;
use Image;
use App\Restaurant;
use Symfony\Component\HttpFoundation\File\UploadedFile;

public function addPhoto($zip, $street, Request $request)
{
    $this->validate($request, [
        'photo' => 'required|mimes:jpg,jpeg,png,bmp'
    ]);
    $photo = $this->makePhoto($request->file('photo'));
    Restaurant::locatedAt($zip, $street)->addPhoto($photo);
}

protected function makePhoto(UploadedFile $file)
{
    return Photo::named($file->getClientOriginalName())
        ->move($file);
}
以下是照片代码:

public static function named($name)
{
    return (new static)->saveAs($name);
}

protected function saveAs($name)
{
    $this->name = sprintf("%s-%s", time(), $name);
    $this->path = sprintf("%s-%s", $this->baseDir, $this->name);
    $this->thumbnail_path = sprintf("%s/tn-%s", $this->baseDir, $this->name);
    return $this;
}

public function move(UploadedFile $file)
{
    $file->move($this->baseDir, $this->name);
    $this->makeThumbnail();
    return $this;
}

protected function makeThumbnail()
{   
    Image::make($this->path)
        ->fit(200)
        ->save($this->thumbnail_path);
}

这是我自己的代码中的一个示例,我在其中编写了图片的路径

$destinationpath = 'img/' . $propertyid;
  $frontpage = 'img/' . $propertyid. '/frontpage/' ;
  $gallery =  'img/' . $propertyid. '/gallery/' ;
  $thumbpath = 'img/' .$propertyid .'/thumbnails/';
将图像文件移动到进行干预操作的位置 代码将处理图像,更改大小等。我们将保存结果 在各自的文件夹中进行处理,然后删除此图像

$image->move($destinationpath,$filename)


我也做了同样的教程,您应该这样做:

Image::make($this->path.$this->name)->resize(128, 
    128)->save($this->thumbnail_path.$this->name);
而不是这样做:

Image::make($this->path)->fit(200)->save($this->thumbnail_path);

如何做一个var_转储可以给我一个var_转储的例子最后我发现我错了!!谢谢您的建议,因为路径名会使我的代码混淆。顺便说一下,谢谢你的建议!!
Image::make($this->path)->fit(200)->save($this->thumbnail_path);