user4958337
user4958337

Reputation: 35

PHP file timestamp (change Attribut)

I have some pictures in a folder and i rename them with PHP. Unfortunately the change Attribut is set to the current date and time. I just want to keep the original one. Is this possible?

Upvotes: 0

Views: 432

Answers (1)

Ian Drake
Ian Drake

Reputation: 757

Before the rename command, get the file's existing modification time using the filemtime() function, like this: $mtime = filemtime($file);

Then, after the rename command, set the modification time back to that value using the touch() function, like this: touch($file, $mtime, $mtime);

Read more:

Upvotes: 2

Related Questions