Support the ongoing development of Laravel.io →
Requests Input Database
Last updated 2 years ago.
0
Solution

If you use an <input type="file" name="image" value="{{ $post->image }}"> in your post.edit view, browser won't allow you to set its value. (It would be a big security hole otherwise.)

What you can do is just show the header image (in an <img>) in your edit form, keep the file upload input for if user want to replace the image and handle it in update() method accordingly (delete old image file, move new one to public, update post->image field with new location).

0

Thank you Xum. I had considered doing that, but didn't know if that was the best way to handle that. Thanks for the direction :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Yelldon yelldon Joined 2 Mar 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.