ElmosGotAGun's avatar

Laravel 5 Image upload to a post

Been looking around but still havent really find the best solution to this issue.

So basically I want to create a blog with laravel, however I m having trouble with image uploading. I would like to upload image when user are creating the post. Tried using Dropzone as suggested however cant get it working without saving the post first.

Then I had a look at just doing it normally with a file input field. However when the user come and edit, it was painful to have an remove button or a preview.

Anyone come across this and can suggest a solution?

Thanks

0 likes
1 reply
veve286's avatar

Firstly upload the image first using ajax and moved to the temp folder , after that you return file path to the view . And the view will save the path of the image using hidden input , When the user submit the form , You don't have to upload image. Just moved image from the temp folder to anywhere you want and just save the path to the database.

This is my flow.

Please or to participate in this conversation.