PHP ftp_put fails

前端 未结 2 1301
挽巷
挽巷 2020-12-06 20:17

I upload XML file through FTP:

$ftp = \"ftp\";
$username = \"username\";
$pwd = \"password\";
$filename = $_FILES[$xyz][$abc];
$tmp = $_FILES[\'file\'][\'tmp         


        
2条回答
  •  遥遥无期
    2020-12-06 20:58

    This worked:

    // connect and login to FTP server
    $ftp_server = "host";
    $ftp_username = "username";
    $ftp_userpass = "password";
    $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
    $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
    $file ="$abc";
    
    // upload file 
    if (ftp_put($ftp_conn, "/$abc" , $file, FTP_ASCII)){
        echo "Successfully uploaded $file.";
    } else {
        echo "Error uploading $file";
    }
    
    // close connection
    ftp_close($ftp_conn); 
    

提交回复
热议问题