i can upload files to my website and display the file name & view file on new Tab but how would i go about displaying what file type it is ?
For example when a file is uploaded i want it to show a PNG icon when its png file and for a doc file it shows a Doc icon and so on so the user can tell what file is what quickly
// Gives you an array with info, dir, filename, extension, etc..
$info = pathinfo('path/to/file.png');
// Just get extension
$ext = pathinfo('path/to/file.png', PATHINFO_EXTENSION);
@iiCe89 you can have it in your controller.. when you fetch a model and maybe it has a related file/image, you can use that code and send the result to your view.
$directory = '/'; // Refers to /storage/app folder
foreach (Storage::files($directory) as $file) {
// $file holds the filename
// Get the extension
$extension = pathinfo($file, PATHINFO_EXTENSION);
// When the file was last modified, in Unix timestamp
$lastModified = Storage::lastModified($file);
// Turn the timestamp into carbon instance
$lastModifiedCarbon = Carbon::createFromTimestamp($lastModified);
}