如何获取Ftp服务器上的文件可以通过账号密码,使用Xftp进行链接 XFtp连接通过代码获取,本文主要是通过php代码获取Ftp上的文件,并且去重。privatehostname;地址privateusername;privatepassword;privateport21;privateconnidFALSE;FTP登陆accessprivatereturnbooleanprivatefunctionlogin(){returnftplogin(thisconnid,thisusername,thispassword);}关闭FTPaccesspublicreturnbooleanpublicfunctionclose(){if(!thisisconn()){returnFALSE;}returnftpclose(thisconnid);}判断conidaccessprivatereturnbooleanprivatefunctionisconn(){if(!isresource(thisconnid)){if(thisdebugTRUE){thiserror(ftpnoconnection);}returnFALSE;}returnTRUE;}下载accesspublicparamstring远程目录标识(ftp)paramstring本地目录标识paramstring下载模式autoasciireturnbooleanpublicfunctiondownload(remotepath,localpath,modeauto){if(!thisisconn()){returnFALSE;}mode(modeascii)?FTPASCII:FTPBINARY;resultftpget(thisconnid,localpath,remotepath,mode);if(resultFALSE){if(thisdebugTRUE){thiserror(ftpunabletodownload:localpath〔。localpath。〕remotepath〔。remotepath。〕);}returnFALSE;}returnTRUE;}获取目录文件列表accesspublicparamstring目录标识(ftp)returnarraypublicfunctionfilelist(path。){if(!thisisconn()){returnFALSE;}returnftpnlist(thisconnid,path);} 以上是ftp一些基础操作,连接,获取文件列表,下载文件,需要获取代码可以私信我获取, 接下来需要进行获取文件操作,并且去除重复的获取本地文件获取远程文件对比本地没有的文件并且下载对下载的文件进行相关操作获取远程文件列表privatefunctiongetRemoteFileList(path,config){thisftpnewFtp(config);resthisftpconnect(config);if(res){fileArrarray();listthislistFtpDir(path,fileArr);thisftpclose();returnlist;}returnfalse;}privatefunctionlistFtpDir(dir,fileArr){datathisftpfilelist(dir);if(!isarray(data)){return;}foreach(dataasvalue){if(thisisjsonfile(value)){fileArr〔〕value;}else{thislistFtpDir(value,fileArr);}}returnfileArr;}publicfunctionfile(dataDir){获取本地文件列表localFileListthisgetBrLocalFileList(dataDir,FLIE);if(count(localFileList)0){foreach(localFileListaskeyvalue){localFileList〔key〕strreplace(self::FTPFILEDIR,,value);}}获取远程文件列表remoteFileListthisgetBrRemoteFileList(dataDir,FLIE);获取本地没有的文件列表remoteArrarray();if(count(localFileList)0){foreach(remoteFileListaskeyvalue){if(!inarray(value,localFileList)){remoteArr〔〕value;}}}else{remoteArrremoteFileList;}下载文件,对于本地有的不会进行二次下载,上面方法已经过滤然后对文件需要的操作,}下载远程文件privatefunctiondownRemote2LocalWget(localFtpDir,list,config){thisftpnewftp(config);thisftpconnect();foreach(listasvalue){dirlocalFtpDir。。substr(value,0,strripos(value,));if(!isdir(dir))mkdir(dir,0777,true);本地存在则删除if(isfile(localFtpDir。。value)){unlink(localFtpDir。。value);}if(!isfile(localFtpDir。。value)){filesizethisftpftpfilesize(value);if(!filesize){echo服务端文件为空!。;}else{rethisftpdownload(value,dir。。substr(value,strripos(value,)1,strlen(value)1));if(re){echo下载。value。成功!。;}else{echo下载。value。失败!。;}}}}thisftpclose();} 上面是FTP下载文件一些基本操作,只贴了部分代码。如有出入,可以后台联系我,欢迎指正。