I'm inserting data into the database using a form on create template. All data inserts, however I have an image upload field on the form which inserts a "xxxxxx.tmp" path into the database.
Here is my store method (Laravel 5):
public function store(Website $website, CreateWebsiteRequest $request)
{
You need to move the file, and then store the file name into the database. Currently you are saving the website (with the temp name), and then moving the file. Try this:
public function store(Website $website, CreateWebsiteRequest $request) {
$request->file('thumbnail')->move(public_path('images'), $request->file('thumbnail')->getClientOriginalName());
$website->thumbnail = public_path('images') . '/' . $request->file('thumbnail')->getClientOriginalName();
// Any other fields to be saved here..
$website->save();
return redirect()->route('websites.index');
}
Hi @stefkay, you could try the below code.. But also look into creating a "WebsiteCreator" service class. You can find videos about creating service classes here on Laracasts.