php - File won't upload to ftp server -


i'm trying upload file webserver game server through script. problem can't find directory.

the full directory /174.34.132.106 port 27015/tf/addons/sourcemod/configs/tf2items.weapons.txt

this path didn't work asked hosting , insisted /tf/addons/sourcemod/configs/tf2items.weapons.txt correct path doesn't work either. game server running on windows server , i'm pretty sure web server running on linux. code wrong, have replace spaces in directory %20. in advance!

    $ftp_server="174.34.132.106"; $ftp_user_name="username"; $ftp_user_pass="password";     $remote_file = "tf2items.weapons.txt"; $file = "weapons/tf2items.weapons.txt";//tobe uploaded  if(!file_exists($file)) echo "the local file not exist";    $conn_id = ftp_connect($ftp_server) or die('unable create connection');  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);   ftp_chdir($conn_id, "174.34.132.106 port 27015/tf/addons/sourcemod/configs/"); echo ftp_pwd($conn_id);  if (ftp_put($conn_id, $remote_file, $file, ftp_ascii)) {     echo "successfully uploaded $file\n";     exit;  } else {    echo "there problem while uploading $file\n";    exit;    }    // close connection    ftp_close($conn_id);  

i noticed ftp server you're connecting using non-standard port, it's not making connection. need specify port in ftp_connect, so:

$ftp_server="174.34.132.106"; $ftp_port = "27015"; $ftp_user_name="username"; $ftp_user_pass="password"; $remote_file = "tf/addons/sourcemod/configs/tf2items.weapons.txt"; $file = "weapons/tf2items.weapons.txt";//tobe uploaded    // set basic connection  $conn_id = ftp_connect($ftp_server,$ftp_port) or die('unable create connection');  

the die() stop script if it's unable make connection. can add same after ftp_login line make sure it's logging in.

edit make sure file exists, try above ftp_put line.

if(!file_exists($file)) echo "the local file not exist"; 

edit 2 after reading down on ftp_put, says remote_file not support directories. you'll need use ftp_chdir first.

ftp_chdir($conn_id, "tf/addons/sourcemod/configs/"); 

then remote_file, use tf2items.weapons.txt. can still use filepaths local file.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -