I would like to change the modification time of an uploaded file because it always returns 01 January 1970, so I am doing the following:
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
touch($_FILES["file"]);
header ('Location: http://www.example.com/php/manager');
// file uploaded but filemtime is 01 Jan 1970
}
you're passing the array to touch()
!! You need to pass $_FILES['file']['tmp_name']
- a string. Actually though, you need to touch $target_file
since that's the final destination; after moving, $_FILES will no longer be there to touch
I will be the first to admit this is not a solution to WHY your dates are not preserving, and I will follow this thread, but to what you're wanting to accomplish, this is the answer.