melloman's avatar

Form model binding for file uploads

I am trying to setup form model binding for when a record is updated so that all the form fields are filled out:

{!! Form::model($logo, ['method' => 'PATCH', 'url' => 'logos/' . $logo->id, 'files'=>true]) !!}

 <div class="form-group">
     {!! Form::label('companyname', 'Company name:') !!}
     {!! Form::text('companyname', null, ['class' => 'form-control']) !!}
</div>

<div class="form-group">
    {!! Form::label('logoimage', 'Logo Upload:') !!}
    {!! Form::file('logoimage', null, ['class' => 'form-control']) !!}
</div>

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

The 'company name' field get pre-filled but how do I use form model binding for the file upload field when it needs to be an object and I have a raw file path string stored in the database?

0 likes
3 replies
bobbybouwmann's avatar

@equipc You will have to get the image by hand and set it yourself. Form model binding can't fix this for you ;)

Chrizzmeister's avatar

i have the same issue, i know model binding can't fix this, but does anyone have an example of the code they use? i cant get it to work properly

Please or to participate in this conversation.