Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bigandy

macrumors G3
Original poster
Apr 30, 2004
8,852
7
Murka
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. :(

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 :eek:

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 :(
 
There isn't any output... I'll post what detail I have soon, I'd kinda given up hope on hearing any replies! :eek:
 
Try putting
PHP:
error_reporting(E_ALL);
at the very top of your PHP script (right after the very first <?php opening tag). That will tell PHP to output everything: errors, warnings, you name it. Maybe that will give us something more to go on. :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.