如何为Laravel集体文件输入赋值

时间:2018-09-15 19:01:16

标签: php laravel file input

你好,我有编辑表单,它有3个输入,两个是文本,一个是文件输入,所以它的编辑形式,所以我必须放置输入的值,这样当提交人时,它将保存他的更改

问题在于,每次您输入此编辑表单时,都需要上传图片,并且我希望从数据库中获取文件输入的值,就像两个文本输入一样,我该怎么做?

{!! Form::model($work,['method' => 'PATCH','enctype' =>         
'multipart/form-data' ,'files' => true ,'action'=>
['worksgallarey@update_work','id'=>$work->id,]]) !!}

<div class="form-group{{ $errors->has('title') ? ' has-error' : 
''}}">
  {{Form::label('title', 'Title')}}
  {{Form::text('title', $work->title, ['class' => 'form-control 
required' , 'placeholder' => 'Enter a title'])}}
</div>

<div class="form-group{{ $errors->has('picture') ? ' has-error' : 
''}}">
    {!! Form::label('picture') !!}
    {!! Form::file('picture')!!}
</div>

<div class="form-group{{ $errors->has('bio') ? ' has-error' : ''}}">
  {{Form::label('bio', 'Bio')}}
  {{Form::text('bio', $work->bio, ['class' => 'form-control 
required', 'placeholder' => 'Write a bio '])}}
</div>
  {{Form::submit('submit',['class' => 'btn btn-primary'])}}

这是我的代码,我尝试过

<div class="form-group{{ $errors->has('picture') ? ' has-error' : 
''}}">
    {!! Form::label('picture') !!}
    {!! Form::file('picture' , $work->picture )!!}
</div>

但没用

1 个答案:

答案 0 :(得分:1)

从技术上来说,您想做的事是不可能的。这是一项安全措施-浏览用户需要手动选择要上传的文件。