Blogger Information
Blog 1
fans 0
comment 0
visits 720
Related recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP 之FTP
Hakim的博客
Original
722 people have browsed it

<?php

/*ftp配置*/

$directory = ''; //ftp文件目录

$config  =array(

                'host'=>$FTPInfo['ftpIP'],                          //服务器IP

                'port'=>$FTPInfo['ftpPort'],                        //端口

                 'username'=>$FTPInfo['ftpUsername'],    //账号

                'password'=>$FTPInfo['ftpPassworld'],     //密码

                'secure'=>true,'passive'=>0);

//secure 是否用 ftp_ssl_connect() true

 //被动模式(PASV)passive 的开关,打开或关闭PASV(1表示开)

$ftps       = new Ftp($config); //new

$listing    = $ftps->connect($config); //链接FTP

/*FTP 文件上传*/

$filelist   = $ftps->getDirListing(); //获取FTP文件目录

$issetDir = 0; //判断文件在FTP是否存在 0不存在

foreach ($filelist as $key => $value) {

    if($value == $directory){

        $issetDir = 1;

    }

}

if($issetDir == 0){//不存在目录

    $ftps->makeDir($directory); //给ftp创建目录

}

$ftps->uploadFile('file/'.$filename,$ftpFile);//上传文件    (要上传的文件,文件上传在ftp的文件名字)

$ftps->disconnect();  //关闭 FTP 

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post