I've got a script that uploads a file, but then, after processing, it needs to FTP it to another server.
The script I've got is as follows. What am I missing, as the php file doesn't actually finish loading if this part of the file is there.
Help much appreciated
edit: the directory should be set by the custom user for this FTP upload script.. but do I need to set that anyway?
also, does it have a limit? is that why it's messing up? can i run FTP from the shell using exec? i know that the linux shell ftp needs user input, can i emulate this? it doesn't work if i do this:
because it needs a carriage return between each command sent
The script I've got is as follows. What am I missing, as the php file doesn't actually finish loading if this part of the file is there.
Code:
$ftp_server = "www.server.net";
$ftp_user_name = "user@server.net";
$ftp_user_pass = "password";
$source_file = "/home/user/public_html/directory/$exefile.ext";
$destination_file = "$exefile.ext";
echo $conn_id = ftp_connect($ftp_server);
echo $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
echo $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}
// close the FTP stream
ftp_close($conn_id);
Help much appreciated
edit: the directory should be set by the custom user for this FTP upload script.. but do I need to set that anyway?
also, does it have a limit? is that why it's messing up? can i run FTP from the shell using exec? i know that the linux shell ftp needs user input, can i emulate this? it doesn't work if i do this:
Code:
ftp www.server.net user@server.net password send /home/user/public_html/directory/file.ext file.ext exit
because it needs a carriage return between each command sent