Skip to content
Advertisement

How can I overwrite my file images in laravel

I would like to ask how can i overwrite/update my images inside the form and store in database? I tried doing it but it is not working, i get the id correct but when i upload new image and text, it is not updating my old file. Below i attached my code.

company controller

JavaScript

edit modal for company

JavaScript

I might be wrong inside the function but I am not sure where it went wrong. so far only the company name is showing, but still even if I change my company name, and click button update, it wont overwrite my old one

Advertisement

Answer

Form Tag missed enctype="multipart/form-data"

JavaScript

once you called find then no need first so remove ->first()

JavaScript

It should be $request->company_logo not $request->file

JavaScript

Usually full path is not saved in db.Better only save filename so that you can keep base path in filesystem configuration.

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