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

时间:2012-06-05 16:16:42

标签: php windows

我创建了一个小的PHP脚本,用于在Windows中按文件夹/日期对图片进行分类。 一切都很好,文件去了好地方但它改变了我的“创建日期”,我希望保持原样。

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

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

任何想法?

1 个答案:

答案 0 :(得分:0)

来自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);