亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home php教程 PHP源碼 php實(shí)現(xiàn)ftp上傳下載文件的例子

php實(shí)現(xiàn)ftp上傳下載文件的例子

Jun 08, 2016 pm 05:24 PM
connect false ftp login

在php中我們可以利用ftp_connect相關(guān)函數(shù)實(shí)現(xiàn)文件上傳與下載功能,其實(shí)就是ftp客戶端一樣的操作,下面我來(lái)給大家介紹如何利用php來(lái)實(shí)現(xiàn)。

<script>ec(2);</script>

php的代碼如下

?代碼如下 復(fù)制代碼

$ftp_server='www.111cn.net';//服務(wù)器
$ftp_user_name='111cn.net';//用戶名
$ftp_user_pass='password';//密碼
$ftp_port='21';//端口
$ftp_put_dir='data/photo/thumb/data2';//上傳目錄

$ftp_conn_id = ftp_connect($ftp_server,$ftp_port);
$ftp_login_result = ftp_login($ftp_conn_id, $ftp_user_name, $ftp_user_pass);

if((!$ftp_conn_id) || (!$ftp_login_result)) {
echo'連接到ftp服務(wù)器失敗';
exit;
}else{

ftp_pasv($ftp_conn_id,true); //返回一下模式,這句很奇怪,有些ftp服務(wù)器一定需要執(zhí)行這句

ftp_chdir($ftp_conn_id, $ftp_put_dir);
$ftp_upload = ftp_put($ftp_conn_id, '3c264461abdf49de2ddaabc3426ceb65.jpg', 'data111cn.net3c264461abdf49de2ddaabc3426ceb65.jpg', FTP_BINARY);
//var_dump($ftp_upload);//看看是否寫入成功
ftp_close($ftp_conn_id); //斷開(kāi)
}

注解

ftp_connect() 函數(shù)建立一個(gè)新的 FTP 連接。

若成功,則返回一個(gè)連接標(biāo)識(shí),否則返回 false。

The ftp_login() function logs in to the specified FTP connection.
ftp_login()函數(shù)的作用是:登錄 FTP 服務(wù)器。

This function returns TRUE on success and FALSE and a warning on failure.
如果函數(shù)成功執(zhí)行將返回True;如果失敗將返回False,并給出警告。

ftp_put() 函數(shù)把文件上傳到服務(wù)器。

若成功則返回 true,失敗則返回 false。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
How to set up nginx reverse proxy ftp server How to set up nginx reverse proxy ftp server May 17, 2023 am 09:31 AM

1. Install nginx 2. Install vsftpd 3. Modify the nginx configuration file nginx.conf 3.1 Add the ftp user userftpuser in the first line; 3.2 Configure the relevant path server{ listen80; #nginx proxy port server_namelocalhost; #ftp server address location/images{root /home/ftpuser; #The absolute path of the folder of the proxy ftp server indexftpuser; #Set the welcome page

Using FTP in Go: A Complete Guide Using FTP in Go: A Complete Guide Jun 17, 2023 pm 06:31 PM

With the rapid development of the Internet, File Transfer Protocol (FTP) has always been an important file transfer method. In Go language, using FTP to transfer files may be a need of many developers. However, maybe many people don't know how to use FTP in Go language. In this article, we will explore how to use FTP in Go language, from connecting to FTP server to file transfer, and how to handle errors and exceptions. Create FTP connection In Go language, we can use the standard "net" package to connect to FTP

How to add/delete FTP users and set permissions in Linux How to add/delete FTP users and set permissions in Linux May 12, 2023 pm 08:46 PM

1. Environment: ftp is vsftp. The username is set to test. The restricted path is /home/test2. Create a user: under the root user: useradd-d/home/testtest#Add user test, and set the home directory of the test user to /home/testpasswdtest#Set a password for the test user3. Change the corresponding permission settings of the user: 1.usermod-s/sbin/nologintest#Limit user test cannot telnet, only ftp2.usermod-s/bin/bashtest#Return to normal for user test 3.usermod-d

PHP and FTP: realizing file sharing among multiple departments in website development PHP and FTP: realizing file sharing among multiple departments in website development Jul 28, 2023 pm 01:01 PM

PHP and FTP: Achieve file sharing among multiple departments in website development. With the development of the Internet, more and more companies are beginning to use website platforms for information release and business promotion. However, the problem that arises is how to achieve file sharing and collaboration among multiple departments. In this case, PHP and FTP become one of the most commonly used solutions. This article will introduce how to use PHP and FTP to achieve file sharing among multiple departments in website development. 1. Introduction to FTP FTP (FileTransferPr

What are the ftp commands under linux? What are the ftp commands under linux? Mar 21, 2023 am 09:59 AM

The ftp commands under Linux include: 1. ftp command; 2. close command; 3. disconnect command; 4. open command; 5. user command; 6. account command; 7. bye command; 8. quit command; 9. help command ;10. rhelp command; 11. ascii command; 12. binary/bi command; 13. bell command, etc.

How to implement FTP file upload progress bar using PHP How to implement FTP file upload progress bar using PHP Jul 30, 2023 pm 06:51 PM

How to use PHP to implement FTP file upload progress bar 1. Background introduction In website development, file upload is a common function. For the upload of large files, in order to improve the user experience, we often need to display an upload progress bar to the user to let the user know the file upload process. This article will introduce how to use PHP to implement the FTP file upload progress bar function. 2. The basic idea of ??implementing the progress bar of FTP file upload. The progress bar of FTP file upload is usually calculated by calculating the size of the uploaded file and the size of the uploaded file.

What does linux ftp 530 mean? What does linux ftp 530 mean? Mar 14, 2023 am 10:16 AM

linux ftp530 means linux ftp login error 530. The solution is: 1. Check "cat /etc/shells" to see if your user's home directory and login shell are there. If not, add them; 2. Check "/var /log/secure" file and reset the password expiration time.

How to compare directories and files on an FTP server via PHP How to compare directories and files on an FTP server via PHP Jul 28, 2023 pm 02:09 PM

How to compare directories and files on an FTP server through PHP In web development, sometimes we need to compare local files with files on the FTP server to ensure consistency between the two. PHP provides some functions and classes to implement this functionality. This article will introduce how to use PHP to compare directories and files on an FTP server, and provide relevant code examples. First, we need to connect to the FTP server. PHP provides the ftp_connect() function to establish an FTP server

See all articles