How to upload a large file to an FTP server using php?

$ftp_server = 'ftp.abc.com';
$remote_file = "myvideo.avi";  // file size 210MB
$file = "myvideo.avi";        // file size 210MB
$conn_id = ftp_connect($ftp_server);  // set up basic connection

// login with username and password
$login_result = ftp_login($conn_id, 'faraz@abc.com', 'password');

ftp_pasv($conn_id, true); // turn passive mode on
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
     echo "successfully uploaded $file\n";
} else {
     echo "There was a problem while uploading $file\n";
}
    // close the connection
    ftp_close($conn_id);

i already edit php.in for
upload_max_filesize = 1024M

 above the fragment working on uploading all types of files,
  but when I try to upload a large file, it uploads to the server, but the size changes after upload.
  The video file size is 210 MB on the local machine
  but after downloading it displayed a file size of 328 KB on the FTP server.
  I have no idea where I can check if someone has a suggestion, then I appreciate

+3
source share
1 answer

Use FTP_BINARYinstead FTP_ASCII. The latter can stop in the first byte of NUL.

, ascii , ascii. , , cgi, shebang, .

+5

All Articles