简体   繁体   中英

Laravel 5.1 form - 'files' => true

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

{!! 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:

<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:

<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?

Your syntax is wrong. The following works for me:

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

使用以下route更改url

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

change It to

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

as Markinson said

Change it to like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM