现在我学会建立一个像Facebook一样的Facebook。昨天,我可以发布状态,但一些修改后,状态发布简化版,工作MethodNotAllowedHttpException在岗位
当我点击提交按钮 扔MethodNotAllowedHttpException
如何解决这一问题? 尝试一些方法,但得到同样的结果
形式:
{{Form::open(array('url'=> 'postStatus','files'=>'true'))}}
{{Form::textarea('status')}}
{{Form::file('picture')}}
{{Form::submit('Post')}}
{{Form::close()}}
路线:
Route::get('/', function()
{
if(Auth::check()){
$post = Newsfeed::all();
return View::make('frontend/home/index')->with('posts', $post->reverse());
}
$months = [];
foreach (range(1, 12) as $month) {
$months[$month] = substr(strftime("%B", mktime(0, 0, 0, $month)), 0, 3);
}
$months = [''=>'Month'] + $months;
return View::make('frontend/register/index')->with('months', $months);
});
Route::post('login', '[email protected]');
Route::get('logout', '[email protected]');
Route::post('register', '[email protected]');
Route::post('upload', '[email protected]');
Route::get('{username}', '[email protected]');
Route::post('postStatus', '[email protected]');
Route::get('deleteStatus/{postid}', '[email protected]');
Route::get('unlike/{likeid}', '[email protected]');
Route::get('like/{postid}', '[email protected]');
Route::post('comment/{postid}', '[email protected]');
Route::get('deleteComment/{commentid}', '[email protected]');
的HomeController
public function postStatus()
{
try{
$status = Input::get('status');
$file = Input::file('picture');
if($file !== '' || $status !=''){
$post = new Newsfeed;
$post->userid = Auth::id();
if($status !=''){
$post->status = $status;
}
if($file != ''){
$rules = array('file' => 'mimes:png,jpg,jpeg');
$validator = Validator::make(array('file'=> $file), $rules);
if($validator->passes()){
$destinationPath = 'images/upload';
$filename = $file->getClientOriginalName();
$file->move('public/'.$destinationPath, $filename);
$post->image = $destinationPath.'/'.$filename;
}
}
$post->save();
}
return Redirect::to('');
}catch(Exception $e){
return Redirect::to('');
}
}
ProfileController可
public function show($fullname)
{
$temp = explode('.',$fullname);
$owner = User::where('firstname', '=', $temp[0])->where('lastname', '=', $temp[1])->first();
if($owner){
return View::make('frontend/profile/index')->with('owner', $owner);
}
return View::make('frontend/profile/notfound');
}
而不是改变用户的路线,我可以改变postStatus的路线?因为我想直接访问配置文件的URL和postStatus只是临时编辑:我改变了用户名路线,但得到了相同的结果 – 2015-02-10 05:54:54
只有当你的'用户名'路线是非常非常最后一个路线在您的路线文件 – Laurence 2015-02-10 05:59:12
但我现在告诉你 - 这会导致问题。如果你的用户名是'upload'或'login'什么的 - 它会和你的其他路线发生冲突。 – Laurence 2015-02-10 05:59:41