我正在处理从我的 php 页面上传的 FTP。
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
flush();
$ftp_server = "myserver";
$ftp_user_name="myuser";
$ftp_user_pass="mypass";
$remote_file="myfile.txt";
$file="myfile.txt";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
// close the connection
ftp_close($conn_id);
?>
它在浏览器中给我一个警告
Warning: ftp_put(): Access is denied. in /var/www/html/ftpcheck.php on line 17. There was a problem while uploading myfile.txt.
我检查了文件的访问权限。但它可以访问。谁能告诉我为什么会这样?
最佳答案
这很可能是权限问题。当您通过 FTP 上传文件时,您还需要检查目录的权限。当您说它可访问时,并不意味着它是可写的。
关于PHP FTP : Access Denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7963363/