Search code examples
coldfusioncoldfusion-9cffile

Preserve Last Modified Date while uploading File


I have an application to upload files to a server.
However, when the files are uploaded, the "Date Modified" changes to the current date/time.

Is there a way to preserve the date of the uploaded file? Or is there a way to change the Date Modified on the uploaded file?

The only answer I have found so far uses Java and dates back to 2006 CFFile and Last Modified Date. Is there a better way to do the same now?


Solution

  • A basic html file upload does not provide the original modification date from the client o/s. However, there is a simpler way to change the modified date of server files, as of CF9+: FileSetLastModified().

    FileSetLastModified(result.serverDirectory &"/"& result.serverFile, dateValue )