The code for PHP is as follows
| The code is as follows |
Copy Code |
|
$ftp _server= ' www.111cn.net ';//server
$ftp _user_name= ' 111cn.net ';//user name
$ftp _user_pass= ' password ';//password
$ftp _port= ' 21 ';//Port
$ftp _put_dir= ' data/photo/thumb/data2 ';//upload Directory
$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 ' failed to connect to FTP server ';
Exit
}else{
FTP_PASV ($ftp _conn_id,true); Return to the pattern, this is strange, some FTP server must be executed this sentence
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);//See if Write succeeded
Ftp_close ($ftp _conn_id); Disconnect
} |
Annotations
The Ftp_connect () function establishes a new FTP connection.
If successful, returns a connection identity, or false.
The Ftp_login () function logs in to the specified FTP connection.
The Ftp_login () function is to log on to the FTP server.
This function returns TRUE to success and FALSE and a warning on failure.
Returns true if the function succeeds, and a warning if the failure returns false.
The Ftp_put () function uploads the file to the server.
Returns true if successful, and returns False if it fails.