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).
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 :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community