1

I want to get modified date of the file that is uploaded but it returns current time (which I guess it's because filemtime returns modified date of temp file so long story short how can I get the true modified date?

here is my code it's (laravel framework)

$file = $request->file;
dd(filemtime($file));
mohammad
  • 47
  • 1
  • 6

3 Answers3

5

Well, you could use Storage::lastModified($path) to get modified date of the file, and don't forget add use Illuminate\Support\Facades\Storage;, hope it will help you guys.

Martin
  • 171
  • 2
  • 5
0
<?php
// outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.

$filename = 'somefile.txt';
if (file_exists($filename)) {
    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}
?>

The above code worked for, try it from your end, let me know, if any errors.

Divyam Solanki
  • 461
  • 2
  • 7
  • 25
  • well I want too get `filemtime` of uploaded file not a file in my directory beside I tried to move the file to my directory and use the above code but it still returns current time – mohammad Sep 30 '16 at 08:18
0

If you want to use protogenous php, you could use filemtime(storage_path("app/yourPath").$file) to get last modified date of the file. Because the storage_path() could get the real path that restore your file. Hope it will help you.

Martin
  • 171
  • 2
  • 5