views:

116

answers:

4

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

+1  A: 

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.

Andy E
Thanks allot! On a side note: Is it a common practice to put the creation date inside the file content? The file is a .w3g (a replay file associated with Warcraft 3). If there is any chance the file creator put the created date inside the file, I'll dedicate some time to dissect it further. Just wondering if there is any "common practice" way, to give me a hint of whether or not the date is in there.
Haemp
+1  A: 

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.

Dan Heberden
I don't understand the difference between being streamed and being copied. Aren't you in both cases simply transferring bytes from one place to another? Or is there a difference in the meta data that is transfered?
Haemp
Well, it was more to help you 'see' the process to make sense. The point is that the created/modified data is saved in the filesystem not the actual file contents. So when the browser sends the file, it just sends the actual file contents and no further information. Flash is really the best option if you need this, as the FileReference class gives you access (client side) to that data that you could manually send with the upload.
Dan Heberden
Yea, its all very clear now. Thank you very much.
Haemp
A: 

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

Mark Baker
A: 

You can string a friendly formatted date to your file names during creation and retrieve latter accordingly.

Babiker