<legend id='FUNAY'><style id='FUNAY'><dir id='FUNAY'><q id='FUNAY'></q></dir></style></legend>

<small id='FUNAY'></small><noframes id='FUNAY'>

        <bdo id='FUNAY'></bdo><ul id='FUNAY'></ul>
    1. <i id='FUNAY'><tr id='FUNAY'><dt id='FUNAY'><q id='FUNAY'><span id='FUNAY'><b id='FUNAY'><form id='FUNAY'><ins id='FUNAY'></ins><ul id='FUNAY'></ul><sub id='FUNAY'></sub></form><legend id='FUNAY'></legend><bdo id='FUNAY'><pre id='FUNAY'><center id='FUNAY'></center></pre></bdo></b><th id='FUNAY'></th></span></q></dt></tr></i><div id='FUNAY'><tfoot id='FUNAY'></tfoot><dl id='FUNAY'><fieldset id='FUNAY'></fieldset></dl></div>

    2. <tfoot id='FUNAY'></tfoot>

      如何使用 PHP 在 FTP 上下载最新的文件?

      时间:2023-10-30
      <tfoot id='pLUWW'></tfoot>

        • <legend id='pLUWW'><style id='pLUWW'><dir id='pLUWW'><q id='pLUWW'></q></dir></style></legend>
            <tbody id='pLUWW'></tbody>
        • <i id='pLUWW'><tr id='pLUWW'><dt id='pLUWW'><q id='pLUWW'><span id='pLUWW'><b id='pLUWW'><form id='pLUWW'><ins id='pLUWW'></ins><ul id='pLUWW'></ul><sub id='pLUWW'></sub></form><legend id='pLUWW'></legend><bdo id='pLUWW'><pre id='pLUWW'><center id='pLUWW'></center></pre></bdo></b><th id='pLUWW'></th></span></q></dt></tr></i><div id='pLUWW'><tfoot id='pLUWW'></tfoot><dl id='pLUWW'><fieldset id='pLUWW'></fieldset></dl></div>

            <bdo id='pLUWW'></bdo><ul id='pLUWW'></ul>

                <small id='pLUWW'></small><noframes id='pLUWW'>

              1. 本文介绍了如何使用 PHP 在 FTP 上下载最新的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 FTP 服务器上有一些文件.此服务器上的任何时间都在上传新文件.我想下载最后一个文件.如何从该服务器获取最后上传的文件?所有文件都有不同的名称.

                On FTP server has some files. For any hour on this server is uploading new files. I'd like to download last file. How can I get last uploaded file from this server? All files are with different names.

                我使用以下脚本下载一个文件.

                I used folowing script to downloading one file.

                $conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
                ftp_login($conn,"user","pass");
                ftp_get($conn,"target.txt","source.txt",FTP_ASCII);
                ftp_close($conn);
                

                提前致谢!!!

                推荐答案

                没有办法确定哪个文件是最新的,因为没有上传时间"属性这样的东西.您没有过多提及 FTP 服务器,但如果您对上传有一定程度的管理,您可以确保在上传时设置上次修改时间.这是否最终起作用取决于您的 FTP 服务器和可能的客户端.

                There is no way to be sure which file is the most recent, as there is no such thing as an "uploaded time" attribute. You didn't mention much about the FTP server, but if you have some level of management over the uploads, you could ensure that the last modified time is set on upload. Whether this ends up working is down to your FTP server and possibly clients.

                假设您的修改时间等于上传时间,您可以执行以下操作:

                Assuming your modified times are equivalent to upload times, you could do something like this:

                // connect
                $conn = ftp_connect('ftp.addr.com');
                ftp_login($conn, 'user', 'pass');
                
                // get list of files on given path
                $files = ftp_nlist($conn, '');
                
                $mostRecent = array(
                    'time' => 0,
                    'file' => null
                );
                
                foreach ($files as $file) {
                    // get the last modified time for the file
                    $time = ftp_mdtm($conn, $file);
                
                    if ($time > $mostRecent['time']) {
                        // this file is the most recent so far
                        $mostRecent['time'] = $time;
                        $mostRecent['file'] = $file;
                    }
                }
                
                ftp_get($conn, "target.txt", $mostRecent['file'], FTP_ASCII);
                ftp_close($conn);
                

                这篇关于如何使用 PHP 在 FTP 上下载最新的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:PHP ftp_put 失败,并出现“警告:ftp_put (): PORT 命令成功" 下一篇:使用 PHP 将单个图像文件上传到 FTP

                相关文章

              2. <i id='Zky18'><tr id='Zky18'><dt id='Zky18'><q id='Zky18'><span id='Zky18'><b id='Zky18'><form id='Zky18'><ins id='Zky18'></ins><ul id='Zky18'></ul><sub id='Zky18'></sub></form><legend id='Zky18'></legend><bdo id='Zky18'><pre id='Zky18'><center id='Zky18'></center></pre></bdo></b><th id='Zky18'></th></span></q></dt></tr></i><div id='Zky18'><tfoot id='Zky18'></tfoot><dl id='Zky18'><fieldset id='Zky18'></fieldset></dl></div>
              3. <legend id='Zky18'><style id='Zky18'><dir id='Zky18'><q id='Zky18'></q></dir></style></legend>

                  <bdo id='Zky18'></bdo><ul id='Zky18'></ul>

                  <small id='Zky18'></small><noframes id='Zky18'>

                  1. <tfoot id='Zky18'></tfoot>