The documentation says it's easy enough ... filectime(). However, when I use it I always get the current time!

I browse to find the file using getfile.php and then upload using uploadfile.php. In the upload file I try to get the file creation time using filectime(), but, like I said, I always get the current time. I have also tried filemtime() with the same results.

What am I doing wrong?

GETFILE.PHP

<form enctype="multipart/form-data" name="frmUploadFile" action="uploadfile.php" method="post">
<td>
 File Location:
</td>
<td >
  <input type="file" name="fileUpload" size="20"></font>
</td>
</form>

UPLOADFILE.PHP

<?
global $fileUpload;

if (file_exists($fileUpload)) {
   echo "$fileUpload was last modified: " . date ("F d Y H:i:s.", filectime($fileUpload));
}

?>

    Well, that's because file uploads don't preserve creation/modification times. Therefore, you're obvioulsy getting the current time because... that's when the file was created/modified!

    The only way you're going to have a chance at preserving such times is using FTP to upload the files to a server that is both capable of setting the times and also allows this feature.

      After all, the uploaded file on your server isn't the same file as the one on the client - it's a (freshly-created) copy.

        Write a Reply...