Image source not readable in Laravel 5.2 - Intervention Image

前端 未结 6 1621
孤独总比滥情好
孤独总比滥情好 2021-02-07 18:27

I have a small problem concerning the resizing process of a given image, I am trying to submit a form containing an input type -->file<-- I was able to upload a picture witho

6条回答
  •  感情败类
    2021-02-07 18:51

    Shouldn't it be Image::make($file->getRealPath()) instead of Image::make('public/uploads/', $file->getRealPath())?

    Image::make() doesn't seem to take two arguments, so that could be your problem.

    Try this:

    $file = Input::file('file');
    $fileName = time() . '-' . $file->getClientOriginalName();
    
    $file->move('uploads', $fileName);
    
    $img = Image::make($file->getRealPath())
        ->resize(320, 240)
        ->save('public/uploads/', $file->getClientOriginalName());
    

    Or if you want to do it without moving the file first, try this:

    $file = Input::file('file');
    $img = Image::make($file)
        ->resize(320, 240)
        ->save('public/uploads/', $file->getClientOriginalName());
    

提交回复
热议问题