【发布时间】:2017-03-04 13:09:34
【问题描述】:
我目前正在处理 Laravel-5.3 中的图像上传。 我的“个人资料页面”路线定义为:
/* GET request to show the profile page */
Route::get('/{username}', [
'uses' => '\App\Http\Controllers\ProfileController@getProfile',
'as' => 'profile.index',
]);
/* POST request to update the Avatar (display pic) */
Route::post('/{username}', [
'uses' => '\App\Http\Controllers\ProfileController@updateAvatar',
'as' => 'profile.index',
]);
因此,个人资料 URL 看起来很像 example.com/john(让“john”成为用户名)
但在表单中,我必须定义“动作”。
<form enctype="multipart/form-data" action="" method="POST">
如何在表单操作中定义路由,以便将用户重定向到各自的路由;类似于“example.com/john”。
我想我不能直接定义<form action="/{username}">,因为我会被带到example.com/{username}。
【问题讨论】:
-
您有 2 条路线名称相同。
标签: php forms laravel laravel-5 laravel-5.3