所以我试图将文件从本地目录移动到远程服务器,我编写了下面的脚本,但我可以在我的问题标题上出现这个令人讨厌的错误:
<?php
//$path = "docs";
$path = $_GET["source"];
$latest_ctime = 0;
$latest_filename = '';
$results_file_dir = "results/linsyn.xml";
$results_rmt_file_dir = "linsyn.xml"
//FTP Details
$ftp_server = "ftp://81.xxxx.88.xxxx";
//FTP User Name
$ftp_user_anme = "xxxxxxxx";
$ftp_user_pass = "xxxxxxxxx";
$d = dir($path);
while (false !== ($entry = $d->read())) {
//set up basic connection
$conn_id = ftp_connect($ftp_server);
//login with username & password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$filepath = "{$path}/{$entry}";
// could do also other checks than just checking whether the entry is a file
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
$xml=simplexml_load_file("docs/" . $latest_filename);
//Last element in XML
$last = $xml->xpath("/DocumentElement/Datas[last()]");
//echo $last[0]->BrightnessPercentage;
$str = $last[0]->BrightnessPercentage;
$final_string = trim($str, "%");
//implicitly creates file
$handle = fopen($results_file_dir, 'w') or die('Cannot open file: '.$results_file_dir);
$head = "all \r\n$final_string";
fwrite($handle, $head);
//Turn passive mode on
ftp_pasv($conn_id, true);
//UPLOAD FILE via FTP
if (ftp_put($conn_id, $results_rmt_file_dir, $results_file_dir, FTP_ASCII)) {
echo "successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
// close the connection
ftp_close($conn_id);
echo "File is created";
}
}
?>
我真的试图在网上找到一些东西,但没有运气!我希望你们之前有过这样的事情!
非常感谢任何提示或解决方案 - 谢谢