Reputation: 529
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
Upvotes: 8
Views: 12902
Reputation:
In addition to the work-around answers or reliance on embedded information, it is worth noting that the idealised general answer is that if browsers/UAs implement multipart/form-data POST using what's available in RFC2183.
They can utilise the additional parameters of the Content-Disposition
header to add in additional meta data such as creation and modification dates.
I do not know if any browsers do at the moment. But the technical specification is there and as far as I can see it is compatible with RFC2388.
Upvotes: 1
Reputation: 18798
You can string a friendly formatted date to your file names during creation and retrieve latter accordingly.
Upvotes: 0
Reputation: 212412
Depending on the type of file, it might be possible: for example, MS Office, Open Office, PDF, and many other types hold a "created date" value within the file properties.... although you'd need to open the file and read the relevant information.... and it will vary from filetype to filetype
Upvotes: 0
Reputation: 11068
No, the stream of data is written to a file in the tmp dir instead of the file being simple 'copied' to your webserver, to it's technically a 'new' file.
Upvotes: 3
Reputation: 344557
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.
Upvotes: 13