php操作apache服务器上的ftp

在此之前,请先在window7上搭建apache-ftp服务器,请查看文章:Windows 上搭建Apache FtpServer

test.php

<?php 
set_time_limit(0);
$ftpServer='localhost';
if (!$ftp=ftp_connect($ftpServer,2121,30)) {
    die('Connection failed');
}
if (!ftp_login($ftp, 'admin', 'admin')) {
    die('Login failed');
}
echo "<pre>Files Available:\n";
$files=ftp_nlist($ftp, '/');
foreach ($files as $file) {
    echo $file."\n";
}
echo "</pre>";
 ?>

 

posted @ 2017-01-08 16:34  屌丝IT男  阅读(336)  评论(0编辑  收藏  举报