使用PHP / CURL通过FTP获取修改日期 [英] Get modified date via FTP using PHP / CURL

查看:600
本文介绍了使用PHP / CURL通过FTP获取修改日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PHP / CURL时遇到了一个文件干旱,可能有人告诉我如何获取一个给定文件的最后修改日期。 p>非常感谢!

解决方案

尝试这个,它似乎在这里工作,但我只测试了一个服务器: / p>

 <?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);
打印日期('d / m / y H:i:s',$ time);

curl_close($ 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);

这篇关于使用PHP / CURL通过FTP获取修改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆