PHP文件传输脚本..几乎完成!

时间:2011-07-06 22:18:48

标签: php ftp transfer

有人可以弄明白这不起作用吗?我一直在尝试不同的东西,仔细检查语法等但是我得到了我在文件不传输时设置的错误消息。这是我的第一个PHP脚本。

我很感激在此期间我会做任何研究。

使用NetBeans

<?php
$user = "username";
$password = "password";
$server_file = 'mag_hounddog.mp3';
$local_file = 'C:\users\kazuiman\desktop\mag_hounddog.mp3';

$ftp_server = "ftp.mysite.com";

// setup a basic connection to the ftp server
$connectionID = ftp_connect($ftp_server) or die("Connection was Not Successful");

// login with username and password for your account
$loginResult = ftp_login($connectionID, $user, $password);

echo ftp_pwd($connectionID);

// changes the directory to the tvstation you can hard code one in here.

if (ftp_chdir($connectionID, "test1nbiiwcdp_apps/tv2beta/streams/_definst_/")) {
    echo "Current Directory is Now..." . ftp_pwd($connectionID) . "\n";
} else {
    echo "Error Changing Directory .. perhaps it doesn't exist?";
}

// Now to download the files and put them onto your local machine
if (ftp_get($connectionID, $local_file, $remote_file, FTP_BINARY)) {
    echo "Succesfully written $server_file to $local_file\n";
} else {
    echo "There was a problem with the FTP transfer please check script\n";
}

// close the connection
ftp_close($connectionID)

?>

1 个答案:

答案 0 :(得分:1)

您从未定义变量$remote_file

在你的序言中,它被称为$server_file

这是复制粘贴错误吗?