search
HomePHP LibrariesOther librariesPHP operation ftp class
PHP operation ftp class
<?php
class ftp
{
  public $off;             // 返回操作状态(成功/失败)
  public $conn_id;           // FTP连接
  function __construct($FTP_HOST,$FTP_PORT,$FTP_USER,$FTP_PASS)
  {
    $this->conn_id = @ftp_connect($FTP_HOST,$FTP_PORT) or die("FTP服务器连接失败");
    @ftp_login($this->conn_id,$FTP_USER,$FTP_PASS) or die("FTP服务器登陆失败");
    @ftp_pasv($this->conn_id,1); // 打开被动模拟
  }
  function up_file($path,$newpath,$type=true)
  {
    if($type) $this->dir_mkdirs($newpath);
    $this->off = @ftp_put($this->conn_id,$newpath,$path,FTP_BINARY);
    if(!$this->off) echo "文件上传失败,请检查权限及路径是否正确!";
  }

Method: FTP connection

@FTP_HOST -- FTP host

@FTP_PORT --Port

@FTP_USER --Username

@ FTP_PASS -- Password



Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

PHP operation FTP class (upload, download, move, create, etc.), phpftp_PHP tutorialPHP operation FTP class (upload, download, move, create, etc.), phpftp_PHP tutorial

12Jul2016

PHP operates FTP classes (upload, download, move, create, etc.), phpftp. PHP operates FTP classes (upload, download, move, create, etc.), phpftp This article provides a detailed introduction to PHP operating FTP classes, php implements FTP upload, FTP download, FTP move, FTP creation, etc. for your reference

What are some very useful class libraries or tool libraries for PHP?What are some very useful class libraries or tool libraries for PHP?

06Jul2016

What are some very useful class libraries or tool libraries for PHP?

PHP value mysql operation class, php value mysqlPHP value mysql operation class, php value mysql

06Jul2016

PHP value mysql operation class, php value mysql. PHP value mysql operation class, php value mysql ?php/** * Created by PhpStorm. * User: Administrator * Date: 2016/6/27 * Time: 18:55 */Class Mysqls{ private $table; //table private $opt; public f

How Do I Link Static Libraries That Depend on Other Static Libraries?How Do I Link Static Libraries That Depend on Other Static Libraries?

13Dec2024

Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

PHP value mysql operation class, php value mysql_PHP tutorialPHP value mysql operation class, php value mysql_PHP tutorial

12Jul2016

PHP value mysql operation class, php value mysql. PHP value mysql operation class, php value mysql ?php/** * Created by PhpStorm. * User: Administrator * Date: 2016/6/27 * Time: 18:55 */Class Mysqls{ private $table; //table private $opt; public f

Complete example of PHP database operation Helper class, phphelper_PHP tutorialComplete example of PHP database operation Helper class, phphelper_PHP tutorial

12Jul2016

A complete example of PHP database operation Helper class, phphelper. A complete example of the PHP database operation Helper class, phphelper This article describes the PHP database operation Helper class through examples. Share it with everyone for your reference, the details are as follows: PHP operation database is divided into several

See all articles