将参数从视图传递到控制器php laravel

时间:2016-06-10 11:47:19

标签: php laravel routes

在视图文件中

action =“{{route('uploadfile',['file_id'=> 1])}}”method =“post”>

在路线档案中

Route::post('/uploadfile',['uses'=>'FileController@uploadfile','as'=>'uploadfile']);

在控制器中

 public function uploadfile($file_id)
{

}

我的问题是:我如何从视图获取值到控制器而不使用post方法将它们显示到url中它会给出错误。

1 个答案:

答案 0 :(得分:0)

您无法像这样传递变量。您可以使用此方法提交值

在视图文件中

    <?xml version="1.0" encoding="UTF-8"?>
<smileyvideo>
   <video id="8628149">
      <uploader>satsuya.oda@example.com</uploader>
      <title>Bad Apple</title>
      <ratings>
         <rating user="epwager@example.com" value="1" />
         <rating user="ajenk@example.com" value="2" />
      </ratings>
   </video>
   <video id="123456">
      <uploader>ajenk@example.com</uploader>
      <title>Musician Cat</title>
      <ratings>
         <rating user="satsuya.oda@example.com" value="3" />
         <rating user="epwager@example.com" value="3" />
         <rating user="ajenk@example.com" value="4" />
      </ratings>
   </video>
   <video id="474920">
      <uploader>satsuya.oda@example.com</uploader>
      <title>Shrek</title>
      <ratings>
         <rating user="epwager@example.com" value="1" />
         <rating user="ajenk@example.com" value="1" />
      </ratings>
   </video>
   <!-- Users List -->
   <user>
      <name>Emil P. Wager</name>
      <email>epwager@example.com</email>
   </user>
   <user>
      <name>Satsuya Oda</name>
      <email>satsuya.oda@example.com</email>
   </user>
   <user>
      <name>Anthony J. Jenkins</name>
      <email>ajenk@example.com</email>
      <bio>I am a food scientist, currently working in iceland. Make sure to
check out my blog!</bio>
   </user>
</smileyvideo>

在控制器中

//user[preceding-sibling::video/uploader[avg((following-sibling::ratings/rating/@value))>=3]/text()=//user/email/text()]

试试这个