jeudi 22 octobre 2020

Laravel get file name from folder with File method

Cant figure out how to get file name from folder in ````filePath```

use Illuminate\Support\Facades\File;

    $filePath = storage_path('app/apiFiles/'.auth()->user()->id_message.'/');

    $fileName = File::files($filePath);

    dd($fileName);

dd($fileName) return array but i need only filename is possible to separated from array?

what i need from array is only this filename: "Z1iZ03gEhltPZj2Z2Rxnnuga2eXywheL4pQc5q0I.zip"

 array:1 [▼
    0 => Symfony\Component\Finder\SplFileInfo {#293 ▼
    -relativePath: ""
    -relativePathname: "Z1iZ03gEhltPZj2Z2Rxnnuga2eXywheL4pQc5q0I.zip"
    path: "/var/www/html/domain/storage/app/apiFiles/910960"
    filename: "Z1iZ03gEhltPZj2Z2Rxnnuga2eXywheL4pQc5q0I.zip"
    basename: "Z1iZ03gEhltPZj2Z2Rxnnuga2eXywheL4pQc5q0I.zip"
    pathname: "/var/www/html/domain/storage/app/apiFiles/910960/Z1iZ03gEhltPZj2Z2Rxnnuga2eXywheL4pQc5q0I.zip"
    extension: "zip"
    realPath: "/var/www/html/domain/storage/app/apiFiles/910960/Z1iZ03gEhltPZj2Z2Rxnnuga2eXywheL4pQc5q0I.zip"
   aTime: 2020-10-22 06:46:37
   mTime: 2020-10-22 06:46:37
   cTime: 2020-10-22 06:46:37
   inode: 1308192
   size: 3180822
   perms: 0100644
   owner: 33
   group: 33
   type: "file"
   writable: true
   readable: true
   executable: false
   file: true
   dir: false
   link: false
 }

]



via Chebli Mohamed