【PHP】FTP相关的代码 分类: php 2015...


<html>
<head>
<meta charset="utf-8">
<title>Mirror updatetitle>
head>

<body>

// 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
"
; exit; } echo "Connected to $host
"
; //log in to host $result = @ftp_login($conn,$user,$password); if(!$result) { echo "Error: Could nont log on as $user
"
; ftp_quit($conn); exit; } echo "Logged in as $user
"
; // check file times to see if an update is required //echo "Checking file time...
";
echo "list of file
"
; $listing = ftp_nlist($conn,''); foreach($listing as $filename) { $filename = iconv("GB2312","UTF-8",$filename); echo $filename."
"
; } //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."
"; echo $encode;*/
?>
body>
html>

版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/bingfeng13/p/4669000.html

你可能感兴趣的:(【PHP】FTP相关的代码 分类: php 2015...)