Level 3
read about database: https://laravel.com/docs/5.2/database and eloquent: https://laravel.com/docs/5.2/eloquent
1 like
Hi, somebody please teach me how to save the file name in database? I already know how to store the image in my project by using this method:
public function upload (){
If(Input::hasFile('file')){
$file = Input::file('file');
$destinationPath = public_path(). '/uploads/';
$filename = $file->getClientOriginalName();
$file->move($destinationPath, $filename);
echo $filename;
}
}
and my problem is I dont know how to save the filename. Any help?
Thanks
Got it! Thanks a lot!!!
public function upload (){
If(Input::hasFile('file')){
$file = Input::file('file');
$destinationPath = public_path(). '/uploads/';
$filename = $file->getClientOriginalName();
$file->move($destinationPath, $filename);
echo $filename;
//echo '<img src="uploads/'. $filename . '"/>';
$user = ImageTest::create([
'filename' => $filename,
]);
}
}
I have model named ImageTest and also a field in the database named filename. Thank you so much! :)
Please or to participate in this conversation.