doudonglu3764 2015-09-25 23:41
浏览 138

无法使用php重命名或删除ftp服务器上的文件

I wrote a php script locally on my machine that worked. But when I uploaded it too my ftp server i ran into some issues. Obviously I couldn`t use rename function etc, and had to change to ftp_rename etc. So the problem is that I can't rename or delete any files with my php script. I have tried to change permissions on files and root directory without any luck. I can browse the files, but not rename or delete them. I don't get any error messages either, the file doesn't load and I get a 500 server error if I try to rename or delete. Any suggestions?

$ftp_server = "";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, "username", "password");

$files = ftp_rawlist($ftp_conn, "www/subtitlesyncer/uploads");
ftp_delete($ftp_conn, "www/subtitlesyncer/uploads/newfile.txt")
if (ftp_rename($ftp_conn, "www/subtitlesyncer/uploads/newfile.txt","www/subtitlesyncer/uploads/new_file_edited.txt")) {
    ...
}

I use this settings, but can`t get any error.

ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

This is the file I try to edit:

-rw-r--r-- 1 <username> <username> 130782 Sep 28 14:41 newfile.txt

I did set the permission on folder and subfiles and subfolders to 777 (for testing), but when I create the textfile it gets 644. But I've changed the permissions the textfile to 777 aswell, I still can`t delete it.

  • 写回答

2条回答 默认 最新

  • dseslyh6662605 2015-09-27 06:14
    关注

    Make sure the file matches the permission for user and group that owns the file. If you are trying to delete it as user Apache in group Apache but your file owner is ftp_server in group ftp (or ant other not marching variation) you will have problems. Also, look for errors in your http error log for the particular server. There has to be something.

    评论

报告相同问题?

悬赏问题

  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。