Get modified date via FTP using PHP / CURL

I seem to have come across a documented drought with CURL vs FTP, can anyone tell me how to get the last modified date of this file using PHP / CURL.

Many thanks!

+5
source share
2 answers

Try this, it seems to work fine here, but I tested it on only 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);
+6
source

If you don't need to use curl, look at php ftp_mdtm . It "returns the last modified time for a given file."

+2
source

All Articles