PHP can't fopen remote file

守給你的承諾、 提交于 2019-12-13 08:47:23

问题


I'm making a script to open remote file (ftp) and edit it with fopen and fwrite.I have problem while connecting to ftp.I made this code

     $handle =        fopen("ftp://".$ftp['username'].":".$ftp['password']."@".$ftp['server']."/cstrike/addons/amxmodx/configs/users.ini", "w") or die("ftp error");
fwrite($handle,$text."\n") or die('err2.');

al variables are set.I tried with ftp://... in web page and it works.allow_url_fopen is On... It just says "ftp error"


回答1:


The ftp:// handler only allows creating new files with fopen("ftp://...", "w");.

If the file already exists you can only write to it if you open it with overwriting set, i.e mode w+.



来源:https://stackoverflow.com/questions/10552388/php-cant-fopen-remote-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!