开发者

Get modified date via FTP using PHP / CURL

开发者 https://www.devze.com 2022-12-23 09:29 出处:网络
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.

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".

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号