Получение ошибки: NotReadableException в строке AbstractDecoder.php 302

Я слежу за turtorial о том, как сохранять фотографии и изменять их размеры в виде миниатюр с использованием PHP, Laravel 5.1, MySQL, InterventionImage и получать следующую ошибку при попытке добавить фотографии:

NotReadableException в строке AbstractDecoder.php 302: источник изображения не читается

Похоже, что проблема возникает в коде фотографии ниже в методе makeThumbnail . Исходная фотография хранится в папке с файлами / фотографиями, но файл миниатюр никогда не создается и фотография не сохраняется в базе данных. Я выполнил все шаги и проверил маршруты, модели, контроллеры представлений, но все, похоже, идентично учебнику, поэтому я не уверен, что я делаю неправильно. Ошибка перестает отображаться, если я dd () эту функцию, но я не смогли зафиксировать его после многих попыток.

Фотореалистичная модель:

<?php namespace App; use Intervention\Image\Facades\Image; use Illuminate\Database\Eloquent\Model; use Symfony\Component\HttpFoundation\File\UploadedFile; class Photo extends Model { protected $table = 'flyer_photos'; protected $fillable = ['path' , 'name' , 'thumbnail_path']; protected $baseDir = 'flyer/photos'; public function flyer(){ // creates a new instance of a photo return $this->belongsTo('App\Flyer'); } /** * Build a photo instance from a file upload */ public static function named($name){ return (new static)->saveAs($name); } /** * Setting name, path, and thumbnail_path parameters for Photo instance */ protected function saveAs($name){ //concatenate file name with current time to prevent duplicate entries in db $this->name = sprintf("%s-%s", time(), $name); $this->path = sprintf("%/%s", $this->baseDir, $this->name); $this->thumbnail_path =sprintf("%s/tn-%s", $this->baseDir, $this->name); return $this; } public function move(UploadedFile $file){ // move the file to new location in flyer/photos $file->move($this->baseDir, $this->name); $this->makeThumbnail(); return $this; } /** * Change sizing of thumbnail and save it */ protected function makeThumbnail() { //dd('error test'); Image::make($this->path) ->fit(200) ->save($this->thumbnail_path); } 

Код контроллера:

 <?php namespace App\Http\Controllers; use App\Flyer; use Illuminate\Http\Request; use App\Http\Requests\FlyerRequest; use App\Http\Controllers\Controller; use App\Http; use App\Photo; use Symfony\Component\HttpFoundation\File\UploadedFile; class FlyersController extends Controller { /** * Auth checks to make sure you are logged in before making any adjustments */ public function __construct() { $this->middleware('auth', ['except' => ['show']]); } /** * Display a listing of the resource. */ public function index() { // } /** * Show the form for creating a new resource. */ public function create() { flash()->overlay('Hello World', 'this is the message'); return view('flyers.create'); } /** * Store a newly created resource in storage. */ public function store(FlyerRequest $request) { //persist the flyer Flyer::create($request->all()); //flash messaging flash()->success('Success!', 'Your flyer has been created.'); return view('pages.home');//temporary redirect the landing page } /** * Display the specified resource. */ public function show($zip, $street) { //find the new flyer $flyer = Flyer::locatedAt($zip, $street); return view('flyers.show', compact('flyer')); } /** * Apply photo to the referenced flyer. */ public function addPhoto($zip, $street, Request $request){ //confirmtion that the photo file will be in appropriate format types $this->validate($request, [ 'photo' => 'required|mimes:jpg,jpeg,png,bmp' ]); //build up our photo instance taking the file from dropzone plugin $photo = $this->makePhoto($request->file('photo')); //Save photo and associate it with the Flyer Flyer::locatedAt($zip, $street)->addPhoto($photo); } protected function makePhoto(UploadedFile $file){ //get new photo object with current name return Photo::named($file->getClientOriginalName())->move($file); } } 

Похоже, что ваш путь не задан правильно:

 $this->path = sprintf("%/%s", $this->baseDir, $this->name); 

Не должно быть …

 $this->path = sprintf("%s/%s", $this->baseDir, $this->name); 

Я сделал то же учебное пособие, вы должны сделать это

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);