时间通过FTP上传时

时间通过FTP上传时

本文介绍了文件修改日期/时间通过FTP上传时更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的FTP / PHP问题。在我的一个页面上,我从一个目录加载.txt文件。很简单。我也使用这个显示文本文件的修改日期:

  date('m / d / Y',filemtime($文件)); 

在我的WAMP服务器上工作正常,但是当我通过FTP上传文件时,到何时上传。我目前托管在一个免费的托管服务提供商(freehostia是确切的)。上传时有没有办法保持修改的日期/时间不变?或者,有没有其他的方法可以解决这个问题呢?任何想法都是值得赞赏的。

解决方案

大多数FTP客户端有一个选项可以在上传时保留文件的修改时间 - 它的选项。我知道FileZilla和WinSCP至少支持这一点。但是,只有一些FTP服务器 会承认这一点。



如果你的服务器不支持它,你必须拿出一些其他方法来做你正在做的事情。从长远来看,我建议找一些其他方式,因为通常最后修改的时间不是一个关键的数据,总是保持在备份,文件传输等同步如果日期被存储(例如)在文件中,您不必担心丢失它。


FTP/PHP question here. On one of my pages I load .txt files from a directory. Pretty simple. I also display the modified date of the text file using this:

date('m/d/Y', filemtime($file));

This works fine on my WAMP server but when I upload the files via FTP, the modified date is changed to when they were uploaded. I'm currently hosting on a free hosting provider (freehostia to be exact). Is there any way to keep the modified date/time from changing when it's uploaded? Or is there perhaps an alternative way to go about this? Any ideas are appreciated.

解决方案

There's an option in most FTP clients to preserve modification times of files when uploaded -- hunt around your options for it. I know FileZilla and WinSCP at least support this. Only some FTP servers will acknowledge this, though.

If your server doesn't support it, you'll have to come up with some other method to do what you're doing. In the long run I'd recommend finding some other way anyway, because typically the last modified time isn't a "critical" piece of data that is always kept in sync across backups, file transfers, etc. If the date is stored (for example) in the file, you'll never have to worry about losing it.

这篇关于文件修改日期/时间通过FTP上传时更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 10:54