Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: How to get creation date from uploaded file?

Problem: I want to determine the original file creation time from a file uploaded to my server via PHP.

My understanding is that the file is copied from the client to a temporary file on my server, which then is referenced in the $_FILES var. The temporary file is of course of no use because it was just created. Is there any way I could get the creation date from the clients original file?

Thanks

like image 456
Hampus Ahlgren Avatar asked Jun 10 '10 20:06

Hampus Ahlgren


People also ask

How do I find the original creation date of a file?

To do that you can go to file explorer, click on documents, Click View, add column, and check “Date created” and “Date modified” both. This will show both in documents folder as well.

How can I view uploaded files in PHP?

In PHP, we can access the actual name of the file which we are uploading by keyword $_FILES[“file”][“name”]. The $_FILES is the by default keyword in PHP to access the details of files that we uploaded. The file refers to the name which is defined in the “index. html” form in the input of the file.

Where are uploaded files stored PHP?

php stores all temporary files, that includes uploaded files, in the temporary files directory as specified in the php. ini. Note that for uploads, those files might be removed as soon as the script the file was uploaded to was terminated (so unless you delay that script, you probably won't see the uploaded file).


1 Answers

That data is not sent by the browser, so there's no way to access it. The data sent along with the file is mime-type, filename and file contents.

If you want the creation date, you'll either need the user to provide it or create a special file uploading mechanism via Flash or Java.

like image 174
Andy E Avatar answered Oct 20 '22 11:10

Andy E