I seem to be running into a documentation drought with CURL vs FTP, can anyone tell me how to get the last modified date of a given file using PHP 开发者_如何转开发/ CURL.
Many thanks!
Try this, it seems to work ok here but I have only tested it on one server:
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,"ftp://server/file");
curl_setopt($curl, CURLOPT_USERPWD, "user:pass");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_NOBODY, 1);
curl_setopt($curl, CURLOPT_FILETIME, TRUE );
$result = curl_exec ($curl);
$time = curl_getinfo($curl, CURLINFO_FILETIME);
print date('d/m/y H:i:s', $time);
curl_close ($curl);
If you don't have to use curl, have a look at php's ftp_mdtm. It "returns the last modified time of the given file".
精彩评论