在我的控制器中,我有一个应该重定向到POST路由的方法。我也不能使这条路线成为GET一条路线。有什么解决办法吗?
我的控制器代码如下所示:
// After a bunch of other if statements, etc
return redirect('newUser')->with('user', $user);
Run Code Online (Sandbox Code Playgroud)
现在我的路线(在 web.php 中)如下:
Route::post('/newUser', function() {
$user=session('user');
dd($user);
return view('profileNewUser', $user);
});
Run Code Online (Sandbox Code Playgroud)
向我抛出的错误是MethodNotAllowedHTTPException.
我知道我的错误与_token,无论如何我可以允许传递令牌字段吗?我尝试with在我的重定向中使用 传递它,但这也不起作用。
谢谢你的帮助。
我的网页包含一个要上传的文件,我希望上传的文件只能是 pdf、doc 或 docx。
我的表单标签也有 enctype="multipart/form-data"
我的 html 看起来像:
<div id="cv_upload" class="row">
<div class="col-xs-12">
<input type="file" name='cv'>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
与此相关的 $rules 数组如下:
'cv' => 'mimes:application/pdf,application/doc,application/docx|required'
Run Code Online (Sandbox Code Playgroud)
最后我的消息看起来像:
'cv.required' => 'A selection for C.V. is required before proceeding.',
'cv.mimes' => 'CV must be of the following file type: pdf, doc or docx.'
Run Code Online (Sandbox Code Playgroud)
唯一的问题是,即使在我上传了 pdf 或 doc 之后,我收到的消息也是必需的。我不知道为什么这不能按预期工作。我也尝试删除“应用程序/”,但也没有成功。请帮忙。
我想在特殊情况下验证使用 Laravel。我授权的字段是一本书的名字。因此它可以包含字母字符、数字字符、空格和连字符/下划线/任何其他键。我唯一不希望它在输入任何键之前的开头有空格。所以名称不能是“L”,注意空格,而“LL L”是完全可以接受的。在这种情况下有人可以帮助我吗?
到目前为止,我得到了这样的正则表达式验证:
regex:[a-z{1}[A-Z]{1}[0-9]{1}]
Run Code Online (Sandbox Code Playgroud)
我不确定如何包含其他限制。
我在我的控制器中定义了一个方法,首先检索输入,如果我的数据库中有电子邮件字段,我想返回一个视图.但是,如果电子邮件字段不存在,我想重定向到另一个路由.我也希望将输入传递给该路线.
为了更好地理解我的意思,我的控制器的代码如下:
public function index(Request $request) {
$credentials = $request->all();
if (\App\User::where('email','=',$credentials['email'])->exists()){
//if they are registered, return VIEW called welcome, with inputs
return view('welcome', $credentials);
}
else{//If the user is not in the database, redirect to '/profile' route,
//but also send their data
return redirect('profile', $credentials);
}
Run Code Online (Sandbox Code Playgroud)
我的web.php如下:
Route::post('/profile', function() {
$m = Request::only('email'); //I only need the email
return view('profile', $m);
});
Run Code Online (Sandbox Code Playgroud)
但是,此逻辑失败并出现错误:'HTTP状态代码'1'未定义'.反正这样做了吗?(即从我的控制器方法转到另一条路线?)
我有一个LabVIEW代码片段。问题是我正在从事一个更大的项目,因此放弃了在该项目中使用LabVIEW。有没有一种方法可以在无需学习所有LabVIEW的情况下就能解密LabVIEW中该程序的工作?我只需要知道最终施加的电压和电流即可。我已经计算出该程序输出的脉冲序列具有20 Hz和200微秒的脉冲持续时间。有一种方法可以在LabVIEW上模拟这种程序,而不是学习每个组件的作用吗?