如何在远程文件夹PHP中获取最新文件?

时间:2017-05-26 15:50:29

标签: recent-file-list

我尝试获取文件夹的最新文件,但它不起作用。 我的文件夹有一个带有html的URL:// ...这可能是问题吗? 这是我测试的...... 感谢

$path = "http://wwww.site.com/myfolder"; 

$latest_ctime = 0;
$latest_filename = '';    

$d = dir($path);
while (false !== ($entry = $d->read())) {
  $filepath = "{$path}/{$entry}";
  // could do also other checks than just checking whether the entry is a file
  if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
    $latest_ctime = filectime($filepath);
    $latest_filename = $entry;
  }
}

OR

{{ }}

1 个答案:

答案 0 :(得分:0)

您需要替换此代码:

$path = "http://wwww.site.com/myfolder";

有了这个:

$path = "myfolder";