PHP 文件传输脚本.. 即将完成!

发布于 2024-11-18 16:57:45 字数 1248 浏览 3 评论 0原文

有人能弄清楚这不起作用吗?我不断尝试不同的事情,仔细检查语法等,但当文件不传输时,我收到了我设置的错误消息。这是我的第一个 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)

?>

Can someone figure out what this is not working? I kept trying different things, double checking syntax etc but I get the error message I have setup for when a file does not transfer. This is my first PHP script.

I appreciate any help I will do research in the meantime.

Using 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)

?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖风昔人 2024-11-25 16:57:45

您从未定义过变量$remote_file

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

这是复制粘贴错误吗?

You have never defined the variable $remote_file.

In your preamble it is called $server_file.

Is this a copy-paste-error?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文