PHP脚本从另一台服务器获取文件并保存在我的服务器上

时间:2017-03-14 21:30:22

标签: php ftp cron

我一直在玩一些PHP脚本试图首先至少得到php文件连接到我的分销商文件上的ftp然后我希望它保存在我的文件中。我打算将它保存为每天运行此脚本的cron。我无法连接到经销商ftp。他们的ftp访问是ftp.aphrodite.WEBSITE.net 该文件的确切位置是ftp.aphrodite.WEBSITE.net/exporting/xml/products.xml 我可以使用filezilla和我的浏览器访问它。这对我来说是一种不同的语言。任何帮助都会很棒!

<?php
$conn_id = ftp_connect("ftp.aphrodite.WEBSITE.net/exporting/xml/products.xml");
$login_result = ftp_login($conn_id, "USERNAME", "PASSWORD");

if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
exit;
} else {
echo "Connected";
}

// get the file
$local = fopen("products.xml","w");
$result = ftp_fget($conn_id, $local,"httpdocs/products.xml", FTP_BINARY);

// check upload status
if (!$result) {
echo "FTP download has failed!";
} else {
echo "Downloaded";
}

// close the FTP stream
ftp_close($conn_id);
?> 

如果我不使用ftp文件的完整网址,我在使用浏览器时无法登录。

1 个答案:

答案 0 :(得分:0)

您向Sub TestDeleteRows() Dim rFind As Range Dim rDelete As Range Dim strSearch As String Dim sFirstAddress As String Dim sh As Worksheet strSearch = "Completed" Set rDelete = Nothing Application.ScreenUpdating = False For Each sh In ThisWorkbook.Sheets With sh.Columns("A:AO") Set rFind = .Find(strSearch, LookIn:=xlValues, LookAt:=xlPart, SearchDirection:=xlNext, MatchCase:=False) If Not rFind Is Nothing Then sFirstAddress = rFind.Address Do If rDelete Is Nothing Then Set rDelete = rFind Else Set rDelete = Application.Union(rDelete, rFind) End If Set rFind = .FindNext(rFind) Loop While Not rFind Is Nothing And rFind.Address <> sFirstAddress rDelete.EntireRow.Delete Set rDelete = Nothing End If End With Next sh Application.ScreenUpdating = False End Sub 提供了错误的参数,此函数接受主机名作为参数,而不是网址。

ftp_connect()