【PHP】FTP相关的代码

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Mirror update</title>
</head>

<body>
<?php
// set up variables - change these to suit application
$host = 'localhost';
$user = 'test';
$password = 'test';

$conn = ftp_connect($host);
if(!$conn)
{
    echo "ERROR: could not connect to ftp srver<br/>";
    exit;
}
echo "Connected to $host<br />";

//log in to host

$result = @ftp_login($conn,$user,$password);
if(!$result)
{
    echo "Error: Could nont log on as $user<br />";
    ftp_quit($conn);
    exit;
}
echo "Logged in as $user<br />";

// check file times to see if an update is required

//echo "Checking file time...<br/>";
echo "list of file<br>";

$listing = ftp_nlist($conn,'');

foreach($listing as $filename)
{
    $filename = iconv("GB2312","UTF-8",$filename);
    echo $filename."<br>";
}

//var_dump($listing);

//$temp = $listing[0];
//$encode = mb_detect_encoding($temp, array("ASCII","UTF-8","GB2312","GBK","BIG5")); 
/*  检测字符编码
三个参数分别是:被检测的输入变量、编码方式的检测顺序(一旦为真,后面自动忽略)、strict模式
对编码检测的顺序进行调整,将最大可能性放在前面,这样减少被错误转换的机会。
一般要先排gb2312,当有GBK和UTF-8时,需要将常用的排列到前面。 */
/*$temp = iconv("GB2312","UTF-8",$temp);
echo $temp."<br>";
echo $encode;*/
?>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值