• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP FTP 类

php 搞代码 4年前 (2022-01-23) 19次浏览 已收录 0个评论
<?php/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the e8本文来源gao.dai.ma.com搞@代*码(网$
搞代gaodaima码

ditor. *//** * Description of FTP * * @author admin */class FTP { public $conn; public $username; public $password; public $ftp_url; public function __construct($username = '', $passwrod = '', $url = '127.0.0.1') { $this->ftp_url = $url; $this->username = $username; $this->password = $passwrod; } //连接FTP服务器 public function connect() { if (!($this->conn = ftp_connect($this->ftp_url))) { return false; } else { return true; } } //登录 public function login() { if (!ftp_login($this->conn, $this->username, $this->password)) { return false; } else { return true; } } //获取服务器系统类型 public function getSysType() { return ftp_systype($this->conn); } //获取当前目录 public function getCurrentDir() { return ftp_pwd($this->conn); } //显示文件列表 public function listFiles($dir_name = '.') { return ftp_nlist($this->conn, $dir_name); } //显示详细文件列表 public function listFilesOfDetails($dir_name = '') { return ftp_rawlist($this->conn, $dir_name); } //下载文件 public function downloadFile($local = '', $remote = '', $type = FTP_ASCII) { if (ftp_get($this->conn, $local, $remote, $type)) { return true; } else { return false; } } //上传文件 public function uploadedFile($remote, $local, $type = FTP_ASCII) { if (ftp_put($this->conn, $remote, $local, $type)) { return true; } else { return false; } } //建立目录 public function createDir($dirname) { return ftp_mkdir($this->conn, $dirname); } //切换目录 public function chdir($dirname) { return ftp_chdir($this->conn, $dirname); } //删除目录 public function rmdir($dirname) { return ftp_rmdir($this->conn, $dirname); } //退出 public function quitFTP() { return ftp_quit($this->conn); }}
.

以上就介绍了PHP FTP 类,包括了上传文件方面的内容,希望对PHP教程有兴趣的朋友有所帮助。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP FTP 类
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址