A.Wen
A.Wen

Reputation: 223

How to set the value attribute of file input in laravel 5

I have tried like below.

{!! Form::file('image',$value=$fileN) !!}

But display an error like below.

ErrorException in FormBuilder.php line 228: Illegal string offset 'name'

Upvotes: 2

Views: 5354

Answers (1)

The Alpha
The Alpha

Reputation: 146191

Basically, you can't set the value attribute of a file input, you can create the file input using something like this:

{!! Form::file('image'); !!}

This will create the input. The value will be set when the user will click the input and select a file to upload.

To set up the value of a file input dynamically is not allowed for security reasons and it's not because of Laravel but a general rule. Please check this answer to know more about this.

Upvotes: 2

Related Questions