Php ftp_put():中没有此类文件或目录
剧本是:Php ftp_put():中没有此类文件或目录,php,Php,剧本是: <?php $filep = $_FILES['userfile']['tmp_name']; $ftp_server = $_POST['server']; $ftp_user_name = $_POST['user']; $ftp_user_pass = $_POST['password']; $paths = $_POST['pathserver']; $name = $_FILES['userfile']['name']; $conn_id = ftp_conne
<?php
$filep = $_FILES['userfile']['tmp_name'];
$ftp_server = $_POST['server'];
$ftp_user_name = $_POST['user'];
$ftp_user_pass = $_POST['password'];
$paths = $_POST['pathserver'];
$name = $_FILES['userfile']['name'];
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_pasv($conn_id, true);
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user: $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user: $ftp_user_name";
}
$upload = ftp_put($conn_id, $name, $filep, FTP_BINARY, "22");
if (!$upload) {
echo "Error: FTP upload has failed!";
} else {
echo "Good: Uploaded $name to $ftp_server";
}
ftp_close($conn_id);
set_time_limit(300);
?>
当我运行这个php
脚本时,会出现警告:
警告:ftp_put():localfile.txt:第26行的/Applications/XAMPP/xamppfiles/htdocs/temp/index.php中没有此类文件或目录
getcwd()
显示我在/Applications/XAMPP/xamppfiles/htdocs/temp
目录中,在这个目录中有filelocalfile.txt
有什么问题吗?只需更换:
$upload = ftp_put($conn_id, $name, $filep, FTP_BINARY, "22");
致:
文件夹和文件的权限设置为什么?您还使用了不应用于文本文件的
FTP\u BINARY
。使用FTP\u ASCII
。我对建议性编辑提出质疑,并拒绝了它。@Fred ii-权限为读写。如果我使用FTP_ASCII,则会出现另一个错误:“FTP_put():REST:在ASCII模式下不允许恢复传输”,因为“它对我不起作用!!获取相同的错误警告:ftp\u put():
$upload = ftp_put($conn_id, $name, $filep, FTP_BINARY);