Jump to content

FTP: Move from one server to another - Timeout


Paulio

Recommended Posts

Hi,

 

I have created a script that connects to an FTP SERVER... downloads a movie file to the web server then uploads it to a target FTP server. If I move a small file of say 10mb it works well! But if I move a larger moviefile such as a 700mb file it doesn't... The only thing I can think is there is some sort of timeout... Any pointers would be a massive help!

 

I have tried to increase the FTP timeout and also enabled passive mode

 

ftp_set_option($conn2, FTP_TIMEOUT_SEC, 600);

 

<?php

$movefile = "movie 2.avi";

$server1 = array(
"Name" =>"Downloads",
"Host" =>"10.0.1.3",
"User" =>"Paulio",
"Pass" =>"lol",
"Path" =>"/Download/Completed");

$server2 = array(
"Name" =>"files",
"Host" =>"10.0.1.2",
"User" =>"Paulio",
"Pass" =>"lol",
"Path" =>"/Television");


////////////////////////////////// Download file to be moved. //////////////////////////////////
// Connect to server
$conn1 = ftp_connect($server1['Host']);

// Open a session to an external ftp site
$login1 = ftp_login ($conn1, $server1['User'], $server1['Pass']);

ftp_pasv($conn1, true);

// Check open
if ((!$conn1) || (!$login1)) {
echo "Ftp-connect failed!"; die;
}
else {
echo "Connected to " . $server1['Name'] . " FTP server.<br><br>";
}

[b]ftp_set_option($conn1, FTP_TIMEOUT_SEC, 600);[/b]

ftp_chdir($conn1, $server1["Path"]);  


// Moves file to be moved to web NAS drive.
ftp_get($conn1, $movefile, $movefile, FTP_BINARY);

////////////////////////////////// Upload file to be moved. //////////////////////////////////
// Connect to server
$conn2 = ftp_connect($server2['Host']);

// Open a session to an external ftp site
$login2 = ftp_login ($conn2, $server2['User'], $server2['Pass']);

ftp_pasv($conn2, true);

// Check open
if ((!$conn2) || (!$login2)) {
echo "Ftp-connect failed!"; die;
}
else {
echo "Connected to " . $server2['Name'] . " FTP server.<br><br>";
}

[b]ftp_set_option($conn2, FTP_TIMEOUT_SEC, 600);[/b]

ftp_chdir($conn2, $server2["Path"]); 

// Uploads moved file from web NAS drive to destination
ftp_put($conn2, $movefile, $movefile, FTP_BINARY);    
    
//Deletes source file
ftp_delete($conn1, $movefile);

//Deletes temp file
unlink($movefile);

ftp_close($conn1);
ftp_close($conn2);

echo "Complete.";
?>

Thanks, Paul.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.