everything is saved to the database but still receiving the error "C:\xampp\tmp\php417C.tmp" does not exist"
Dec 24, 2016
3
Level 4
file upload not saved to the database
i want to check if the form post an attachment and save it to the database as well as moving the file to the files folder. I get the following error The file "C:\xampp\tmp\php417C.tmp" does not exist" (The file is moved but the attachment column in messages table is empty)
$message = new message;
if($request->hasFile('attachment')){
$message = new message;
$attachment = $request->file('attachment');
//create a file path
$path = public_path('/uploads/files/');
//get the file name
$filename = time() . '.' . $attachment->getClientOriginalExtension();
//save the file to my path
$attachment->move($path , $filename);
//save that to your database $message->attachment = $pathname;
$message->save();
};
Level 4
I fix that thank you @Snapey for your reply . the $message->save(); wasn't in the right order so i run it outside if statement and immediately after I affected the input fields's request to the object variables. and that works fine.
Please or to participate in this conversation.