Laravel 将包含路径的参数传递给控制器

Laravel 将包含路径的参数传递给控制器,laravel,laravel-4,routes,parameter-passing,laravel-routing,Laravel,Laravel 4,Routes,Parameter Passing,Laravel Routing,我试图在Laravel4中传递一个变量,该变量包含从表单到控制器函数的路径,目的是下载一个图像。我尝试了很多东西,但都不管用。如果我没有在路由中传递参数,我会得到一个缺少参数的错误,如果我在路由中传递参数,我会得到一个NotFoundHttpException 这是我的密码: 查看表格: {{ Form::open(array('route' => array('download', $myPath))) }} {{ Form::submit('Download', array('

我试图在Laravel4中传递一个变量,该变量包含从表单到控制器函数的路径,目的是下载一个图像。我尝试了很多东西,但都不管用。如果我没有在路由中传递参数,我会得到一个缺少参数的错误,如果我在路由中传递参数,我会得到一个NotFoundHttpException

这是我的密码:

查看表格:

{{ Form::open(array('route' => array('download', $myPath))) }}
    {{ Form::submit('Download', array('class' => 'generator')); }}
{{ Form::close() }}
路线:

Route::post('/download/{myPath}', array('uses' => 'ImagesController@download', 'as' => 'download'));
图像控制器功能:

public function download($myPath){
    return Response::download($myPath);
}
当我单击submit时,我将获得一个类似以下的URL,其中包含NotFoundHttpException:


我不明白我遗漏了什么。

您实际上发布了两个变量。试试这个

Route::post('/download/{myFolder}/{myFile}', array('uses' => 'ImagesController@download', 'as' => 'download'));
在你的控制器里

 public function download($myFolder, $myFile){
        return Response::download($myFolder.'/'.$myFile);
}

这很有效,谢谢:所以,我不能在路由中传递包含/的变量,对吗?是的-正确-因为它在发布和评估URL时作为另一个变量触发它。但是,您可以使用/在普通$\u post数据本身中post变量。