I have searched a lot for the answer and found some results but none of one is working for me. I want to transfer zip file from one server to another server using ftp functions. File went transferred but without data. Here is my code as follows:
<?php
$file = 'LICENSE.zip';
$fp = 'LICENSE.zip';
$ftp_server = "ftpserver name";
$ftp_user_name = "ftp username";
$ftp_user_pass = "ftp password";
// set up basic connection
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// login with username and password
// upload a file
ftp_chdir($conn_id,'/dev');
if (ftp_put($conn_id, $file, $fp, FTP_BINARY)) {
echo "successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
// close the connection
ftp_close($conn_id);
fclose($fp);
?>
Even I am unable to transfer a simple .php
or .txt
file with their data. In this case only files without data is moving.