Laravel 5.1 表单 - 'files' => true

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39344259/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 14:24:59  来源:igfitidea点击:

Laravel 5.1 form - 'files' => true

phphtmlformslaravellaravel-5.1

提问by Aleks Per

I use Laravel HTML to create form but I have problem, so in creating form I have:

我使用 Laravel HTML 创建表单但我有问题,所以在创建表单时我有:

{!! Form::open(['url'=>'vocuhers','files' => 'true','enctype'=>'multipart/form-data']) !!}

    @include('vouchers.form',['submitButtonText'=>'Click to Add New Vocuher'])

{!! Form::close() !!}

But when I see my HTML form in browser there is just:

但是当我在浏览器中看到我的 HTML 表单时,只有:

<form method="POST" action="http://localhost:8888/vouchers" accept-charset="UTF-8">
   <input name="_token" type="hidden" value="dfgdfgdfgdfgdf">

so where is

那么在哪里

enctype="multipart/form-data"

which allow me to upload files from form ?

这允许我从表单上传文件?

Why I don't get this HTML output:

为什么我没有得到这个 HTML 输出:

<form method="POST" action="https://bedbids.com/chats" accept-charset="UTF-8" enctype="multipart/form-data">
  <input name="_token" type="hidden" value="dsfdfgdfgdfgdfg">

What is the problem here exactly ?

这里到底有什么问题?

回答by Markinson

Your syntax is wrong. The following works for me:

你的语法是错误的。以下对我有用:

{{Form::open(array('url' => 'your_url', 'method' => 'post', 'files' => true))}}

回答by Ravi Hirani

Change urlwith routeas below.

更改urlroute如下。

{{!! Form::open(['route'=>'vocuhers','class'=>'your_class','files'=>true]) !!}} 

回答by Mohammad Khan

{!! Form::open(['url'=>'vocuhers','files' => 'true','enctype'=>'multipart/form-data']) !!}

change It to

将其更改为

{!! Form::open(['url'=>'vocuhers','files' =>true,'enctype'=>'multipart/form-data']) !!}

as Markinsonsaid

正如马金森所说