jaahvicky's avatar

How to save file details into DB in Laravel 5

How to save file details into DB in Laravel 5

I am trying to insert the details of an uploaded file into a database table and I am getting the following error:

Fatal error: Call to undefined method Symfony\Component\Finder\SplFileInfo::getClientOriginalName()

How would I get the getClientOriginalName(), getClientOriginalName() and getFilename() of a file in Laravel5?

Below is my code I am using.

public function add() 
{
$directory = public_path('xml');

$files = File::allFiles($directory);
foreach ($files as $file) {
$entry = new Xmlentry();
$entry->mime = $file->getClientMimeType();
$entry->original_filename = $file->getClientOriginalName();
$entry->filename = $file->getFilename().'.'.$extension;
$entry->save();
}
}
0 likes
2 replies

Please or to participate in this conversation.