【发布时间】:2013-11-07 15:38:13
【问题描述】:
我在我的网站上的 PHP 脚本上创建了一个 .ics 文件,现在我将该文件本地保存在我的计算机中,但我想将它上传到我的 iCal Exchange 帐户,以便我可以从那里共享它。
我可以通过 iCal(应用程序)上传,但我需要通过 PHP 上传。在 iCalExchange 我有一个用户名和密码,指令说:
要从 iCal 发布新日历,请选择“在 Web 上发布 server" 选项,并使用以下 URL 之一:
http://icalx.com/private/zeroan/
http://icalx.com/public/zeroan/
请务必正确输入您的新用户名和密码。
我在 PHP 中尝试过,但没有成功:
$ftp_server='74.91.122.152';//serverip
$conn_id = ftp_connect($ftp_server);
// login with username and password
$user="zeroan";
$passwd="****";
$login_result = ftp_login($conn_id, $user, $passwd);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
die;
} else {
echo "<br>Connected to $ftp_server, for user $user<br>";
}
//directorylike /www.velibaba.com/images
ftp_chdir($conn_id, "http://icalx.com/public/zeroan/");
//$destination_file=ftp_pwd($conn_id);
$source_file='cale.ics';
$destination_file="calendario.ics";
echo ("<br>");
print $destination_file;
echo ("<br>");
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status
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);
谢谢
【问题讨论】:
-
“没有运气”是什么意思?有错误信息吗?
-
错误是:
Warning: ftp_login() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/pruebasmarty/Untitled.php on line 10 FTP connection has failed!@lincb -
您的 ftp_connect() 函数不起作用。该 IP 是否有 FTP 服务器?