2017-02-16 77 views
0

我在处理发布数据时遇到问题。Laravel 5收集发布数据

举例来说,如果我有一个简单的小形式:

<form action='/leads/getpost' method='POST'> 
<input type='text' name='Domain'> 
<input type='submit' name='submit'> 

,然后收集数据,并尝试呼应出来:

public function getPost() 
    { 
     $formData = Request::all() ; 
     var_dump($formData); 

     // 
    } 

我得到一个错误:在MethodNotAllowedHttpException RouteCollection.php 218行:

如果我使用GET做同样的事情,它工作正常。

我尝试过编辑VerifyCsrfToken并补充说:

protected $except = [ 'leads/getpost' 
     // 
    ]; 

仍然没有工作。

+0

http://stackoverflow.com/questions/32718870/how-to-get-all -input-of-post-in-laravel-5 –

+0

@LeszekRepie,我试过这些例子,仍然没有工作 – Matt

+0

https://laracasts.com/discuss/channels/laravel/methodnotallowedhttpexception-in-routecollectionphp-line-218? –

回答

0

尝试这个

路线:

Route::post('leads/getpost', '[email protected]'); 

控制器:

use Request; 

public function getPost() 
    { 
     $formData = Request::all(); 
     var_dump($formData); // or you could return it to the view 

    }