Get last modified time for a file on the FTP server:
<?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
$file = "somefile.txt";
// get the last modified time
$lastchanged = ftp_mdtm($ftp_conn, $file);
if ($lastchanged != -1)
{
echo "$file was last modified on : " . date("F d Y H:i:s.",$lastchanged);
}
else
{
echo "Could not get last modified";
}
// close connection
ftp_close($ftp_conn);
?>
The ftp_mdtm() function returns when the specified file was last modified.
Note: Not all servers support this function, and this function does not work with directories.
ftp_mdtm(
ftp_conn, file);
Parameter | Description |
---|---|
ftp_conn | Required. Specifies the FTP connection to login to |
file | Required. Specifies the file to check |
Return Value: | The last modified time as a Unix timestamp on success, -1 on failure |
---|---|
PHP Version: | 4+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!