相关疑难解决方法(0)

使用Laravel 4进行干预\ Image\Exception\ImageNotWritableException

我正在使用Laravel 4.我不确定为什么当一切看起来都正确时我会收到此错误.此外,产品不会更新到数据库.

错误:干预\ Image\Exception\ImageNotWritableException无法将图像数据写入路径[/img/products/1396668877.jpg]

ProductsController的片段,其中创建了产品对象:

public function postCreate() {
    $validator = Validator::make(Input::all(), Product::$rules);

    if ($validator->passes()) {
        $product = new Product;
        $product->category_id = Input::get('category_id');
        $product->title = Input::get('title');
        $product->description = Input::get('description');
        $product->price = Input::get('price');

        $image = Input::file('image');
        $filename  = time() . '.' . $image->getClientOriginalExtension();
        Image::make($image->getRealPath())->resize(468, 249)->save('/img/products/'.$filename);
        $product->image = 'img/products/'.$filename;
        $product->save();

        return Redirect::to('admin/products/index')
            ->with('message', 'Product Created');
    }

    return Redirect::to('admin/products/index')
        ->with('message', 'Something went wrong')
        ->withErrors($validator)
        ->withInput();
}
Run Code Online (Sandbox Code Playgroud)

产品对象传递给视图

@foreach($products as $product)
                <li>
                    {{ HTML::image($product->image, $product->title, array('width'=>'50')) }} 
                    {{ $product->title }} - 
                    {{ …
Run Code Online (Sandbox Code Playgroud)

upload image laravel

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

image ×1

laravel ×1

upload ×1