使用 PHP 脚本在 Windows 上复制图像,而不修改创建日期


copy image on windows using php script without modifying creation date

我创建了一个小的php脚本来在Windows中按文件夹/日期对图片进行分类。一切都很好,文件去了好地方,但它改变了我的"创建日期",我想保持完整。

我使用了一个非常简单的 php copy() 函数。

我已经使用了touch() + filectime,但仍然无法更改文件的创建日期

知道吗?

来自 php.net:

It's worth noting that copy() sets the destination file's last modified time/date.

使用它有什么问题?

clearstatcache();
$oldstamp = filemtime("file.txt");
copy("file.txt","newfolder/file.txt");
touch("newfolder/file.txt",$oldstamp);