0
ErrorException:クラスのSymfony \コンポーネントの オブジェクト\ HttpFoundationファイル\にUploadedFileは、私のコードのProductControllerエラーの更新画像製品laravel 5
をブールに変換することができませんでした\
public function postEdit($id, Request $request){
$product = product::find($id);
$product->name = Request::input('txtName');
$product->alias = changeTitle(Request::input('txtName'));
$product->price = Request::input('txtPrice');
$product->intro = Request::input('txtIntro');
$product->content = Request::input('txtContent');
$product->keywords = Request::input('txtKeywords');
$product->description = Request::input('txtDescription');
$product->user_id = 1;
$product->categories_id = Request::input('sltParent');
// Phần xử lý edit ảnh
$img_current='resources/upload/'.Request::input('img_current');
if(!empty(Request::file('fImages'))){ // line error
echo "có file";
$file_name=Request::file('fImages')->getClientOriginalName();
$product->image= $file_name;
Request::file('fImages')->move('resources/upload/',$file_name);
if(File::exists($img_current)){
File::delete($img_current);
}
}
else{
echo "Không có file";
}
$product->save();
return redirect()->route('admin.product.list')->with(['flash_level'=>'success','flash_message' => 'Chỉnh sửa sản phẩm thành công']);
}
私のエラー
ありがとうございますが、私はリクエストを使っています:( –
あなたは実際に$ method-> hasFileとisValid()を使って試してみることができますか? – SteD
ok、ありがとう、働いている:D –