0
任何最好的辦法,這將是gratefull最好的方式使用資源和雄辯laravel 4
該做的是什麼樣的一種形式搶輸入,並將其保存到數據庫中這樣做IM。
public function update()
{
$file = Input::file('path');
$destinationPath = 'img/';
$filename = $file->getClientOriginalName();
// $extension =$file->getClientOriginalExtension();
$upload_success = Input::file('path')->move($destinationPath, $filename);
$photo = Photo::find($_POST['id']);
$photo->caption = $_POST['caption'];
$photo->path = $destinationPath . $filename;
$photo->save();
if($upload_success) {
return Redirect::to('photos/'.$_POST['id'].'/edit')->withInput()->with('success', 'Photo have been updated.');
} else {
return Response::json('error', 400);
}
}
這項工作得很好,但我不知道是否有一個簡化的方法來做到這一點怎麼樣我可以從表單POST數據發送更新來更新照片信息,而不是我的使用$ _ POST,並獲得id從表單解析到更新($ id)等。謝謝
你會在你的代碼之前編輯你的問題的主體,這實際上是做什麼的? – halfer