我已经按照代码通过 ftp 以 html 形式上传文件。
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
// $ftp_server = "xxx";
$ftp_server = 'xxx';
$ftp_username = "xxx";
$ftp_password = "xxx";
//setup of connection
$conn_id = ftp_connect($ftp_server) or die("could not connect to $ftp_server");
//login
if(ftp_login($conn_id, $ftp_username, $ftp_password))
{
echo "conectd as $ftp_username@$ftp_server\n";
}
else {
echo "could not connect as $ftp_username\n";
}
$file = $_FILES["uploadedfile"]["name"];
$remote_file_path = "/import/".$file;
ftp_put($conn_id, $remote_file_path, $_FILES["uploadedfile"]["tmp_name"], FTP_ASCII);
ftp_close($conn_id);
echo "\n\nconnection closed";
include("writedb.php");
if (ftp_delete($conn_id, $file)) {
echo "$file deltet successful.\n";
} else {
echo "cant delete: $file\n";
}
?>
除了删除上传的文件外,一切都有效。
错误是这样的:
Warning: ftp_delete(): 1 is not a valid FTP Buffer resource in (correct path) on line 29
cant delete: daten.csv
我的代码有什么问题?
谢谢你们 :)