Blogger Information
Blog 81
fans 1
comment 0
visits 124109
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
larvael 中定义view和表单的csrf
有什么是忘不了的的博客
Original
931 people have browsed it

用tp用习惯了,创建视图的时候 直接创建成index.html了。。。。{{$name}}也不被解析。。。仔细一瞅哎。

laravel中创建视图:

        resources\views下创建

        视图文件名:fileName.blade.php格式 如:index.blade.php

 csrf保护:    

        在视图创建表单的时候需要设置 csrf 否则就会 报419错误

<form action="/index/show/123" enctype="multipart/form-data" method="post" accept-charset="utf-8">
		 @csrf 
		 <!-- {{ csrf_field() }} -->
		 <!-- <input type="hidden" name="_token" value="{{ csrf_token() }}"> -->
		<input type="file" name="file">
		<input type="submit" >
	</form>	

    共三种方法:

        第一种:@csrf

        第二种:{{ csrf_field() }}

        第三种:<input type="hidden" name="_token" value="{{ csrf_token() }}">



Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post