加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP FTP:访问被拒绝

发布时间:2020-12-13 16:22:27 所属栏目:PHP教程 来源:网络整理
导读:我正在从我的php页面上进行FTP上传. ?phperror_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 connectio
我正在从我的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 $filen";
} else {
 echo "There was a problem while uploading $filen";
}

// 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上传文件时,还需要检查目录的权限.当你说它可以访问时,并不意味着它是可写的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读