jeudi 10 mars 2016

How to save file details into DB in Laravel 5.1

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 the 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();
  }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire