PHP: How to get creation date from uploaded file?

Problem: I want to determine the initial time the file was created from a file uploaded to my server via PHP.

I understand that the file is copied from the client to a temporary file on my server, which then refers to $ _FILES var. The temporary file is of course useless because it has just been created. Is there a way to get the creation date from the clients source file?

thanks

+6
php file-upload
source share
5 answers

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

If you need a creation date, you will either need to provide it to the user, or create a special mechanism for downloading files via Flash or Java.

+10
source share

No, the data stream is written to a file in the tmp directory instead of a file that is simply β€œcopied” to your web server, and this is technically a β€œnew” file.

+3
source share

In addition to circumventing the answers or relying on the embedded information, it is worth noting that the idealized general answer is that if the / UA browsers implement POST using multipart / form-data POST using what is available in RFC2183 .

They can use additional Content-Disposition header options to add additional metadata, such as creation and modification dates.

I do not know if there are any browsers at the moment. But a technical specification exists, and as far as I can see, it is compatible with RFC2388 .

+1
source share

Depending on the type of file, this may be possible: for example, MS Office, Open Office, PDF and many other types contain the "created date" value in the file properties .... although you will need to open the file and read the relevant information .... and it will be different from filetype to filetype

0
source share

You can insert a friendly formatted date in the file names during creation and retrieval of the latter, respectively.

0
source share

All Articles