如何使用php

时间:2016-06-08 17:54:09

标签: php ftp

我的服务器有明确的ftp服务器。我想将一个zip文件从该服务器传输到我的新服务器。但是有一些错误.FTP服务器已连接但文件未传输。 zip文件大小为118 MB。请帮帮我。

set_time_limit(0); //Unlimited max execution time

$remote_file = 'zipfile.zip';

/* FTP Account */
$ftp_host = 'example.com'; /* host */
$ftp_user_name = 'username@example.com'; /* username */
$ftp_user_pass = 'password'; /* password */


/* New file name and path for this file */
$local_file = 'zipfile.zip';


/* Connect using basic FTP */
$connect_it = ftp_ssl_connect( $ftp_host );
var_dump($connect_it);

if (@ftp_login($connect_it, $ftp_user_name, $ftp_user_pass))
{
  echo "Connection established.";
}
else
{
   echo "Couldn't establish a connection.";
}

/* Login to FTP */


/* Download $remote_file and save to $local_file */
var_dump(ftp_get( $connect_it, $local_file, $remote_file,FTP_BINARY ));
if ( ftp_get( $connect_it, $local_file, $remote_file,FTP_BINARY ) ) {
   echo "WOOT! Successfully written to $local_file\n";
}
else {
   echo "Doh! There was a problem\n";
}

/* Close the connection */
ftp_close( $connect_it );

出于测试目的,我可以为您提供我的ftp服务器凭据。 请评论我......

0 个答案:

没有答案