Skip to content
Advertisement

Fetch image variable and display on input file

I am trying to update an image and other data in a database, but when I update only text data, the image value becomes null or empty.

JavaScript

This a controller

JavaScript

When I input only the title, left out the image, and tried to dump using dd($image);, I got a null value.

When updating the image, it’s getting updated very well database.

Now, my question is, how do I make sure the value is captured in the input file <input type="file" class="form-control" value="{{$data->image}}" name="image"> so that when I update other data, it also sends the image value. NB: value=”{{$data->image}}” IS NOT capturing the data from database

Advertisement

Answer

Try this code

JavaScript

Please note you should delete the old images if you don’t need anymore

you can use this to delete an old image if you want

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement