首页
开发手册
应用中心
工具
用户中心
FoundPHP FTP Use
FoundPHP FTP 使用
English
中文简体
English
上一篇
下一篇
##FoundPHP FTP Use ### PHP FTP Introduction FThe TP function provides client access to the file server through the File Transfer Protocol (FTP). FTP functions are used to open, log in, and close connections, as well as to upload, download, rename, delete, and obtain file information on the file server. Not all FTP functions work on every server or return the same results. These functions are used for detailed access to the FTP server. If you only need to read and write to the FTP server, it is recommended to use ftp://wrapper in the Filesystem function. ------------ ### SFTP installation SFTP requires a separate installation of components before it can run. We provide installation methods for two platforms. If you don't use sftp in your development, you can ignore the following installation steps.
#####Windows Installation Method php ssh2 extension download address: `http://windows.php.net/downloads/pecl/releases/ssh2/0.12/` Download according to your own PHP version. If you use the PHP5.4 thread-safe ts version, download php_ssh2-0.12-5.4-ts-vc9-x86.zip Here are the extensions for PHP 5.3-5.5: ![](data/files/edit/20/08/09/200809_18205625.png) 1. There will be three files after decompression:libssh2.dll、php_ssh.dll、php_ssh2.pdb 2. Put php_ssh.dll, php_ssh2.pdb in your php extension directory under php/ext/ 3. Copy libssh2.dll to c:/windows/system32 and c:/windows/syswow64 each 4. Add extension=php_ssh2.dll to php.ini 5.Restart apache and check phpinfo() to see if it shows that the php_ssh2 extension has been loaded successfully 6. Then php executes the ssh connection operation. ![](data/files/edit/20/08/09/200809_20453595.png)
#####Linux Installation method The method we explain here uses centos and pagoda control panel, other linux is also similar operation First install libssh yum install libssh2-devel Download ssh2, unzip and install wget http://pecl.php.net/get/ssh2-1.2.tgz #unzip tar -xvf ssh2-1.2.tgz cd ssh2-1.2/ #start compiling phpize ./configure --with-php-config=/www/server/php/70/bin/php-config #Here we set php7 so the directory used is 70, other versions can be found under the directory /www/server/php/ make && make install After compiling, modify php.ini, you can open the pagoda panel and directly add in the php configuration modification extension=ssh2.so After restarting apache or nginx, check phpinfo() to see if the php_ssh2 extension is successfully loaded ![](data/files/edit/20/08/09/200809_20453595.png) ------------
###Link FTP and Close the Link ```php //FTP Settings $FoundPHP_ftpset = array( 'host' => '127.0.0.1', //server 'port' => '21', //port 'username' => 'test', //account number 'password' => '123123', //password 'passive' => 1, //passive mode: 1 to start, 0 to close 'timeout' => '3', //timeout period 'language' => 'cn', //language pack 'logs' => 'ftp_log.txt', //log ); //introduce class library $ftp = load('class/network/ftp','FoundPHP_ftp',$FoundPHP_ftpset); //operation content //close link $ftp->close(); ```