【问题标题】:fopen() and file_get_contents() are disabled, is there another way to write to a file?fopen() 和 file_get_contents() 被禁用,还有另一种写入文件的方法吗?
【发布时间】:2014-11-04 06:52:55
【问题描述】:

我制作了一个覆盖 xml 文件的脚本,它可以在本地运行,但托管公司不允许使用 fopen() 或 file_get_contents()。是否有另一种方法(可能使用 curl)来创建/写入文件?

【问题讨论】:

  • 是否允许system()或类似类型?
  • 服务器上有什么操作系统?
  • 试试fwrite
  • system() 似乎可用,ubuntu 服务器,fwrite 给我一个权限错误
  • 找一家不同的托管公司。

标签: php


【解决方案1】:

正如 cmets 中所揭示的,正在写入的目录的权限设置为 665

为了在目录中创建文件,它必须具有执行权限。

$ mkdir test
$ chmod 665 test/
$ touch test/foo
touch: cannot touch ‘test/foo’: Permission denied
$ cd test/
bash: cd: test/: Permission denied

将权限修改为 755 应该可以解决问题。

chmod 755 test/
$ touch test/foo
$ cd test/
$ ls
foo

如果您可以通过 ssh 访问该框并更改您自己的权限,请执行此操作,否则请联系支持人员,看看他们是否可以为您完成。

【讨论】:

    【解决方案2】:

    如果您可以使用 ftp 协议,您可以这样做。 要获取内容 onlyyu 可以包含和显示。 如果要创建或编辑文件,请使用 ftp 协议。 您不必全部使用 php(我认为),您可以使用 ajax 或 jquery 来添加它

    第二种方法是更改​​文件的权限(chmod)。在控制台或通过 ftp 客户端。 这可以帮助你。

    但在我看来,您必须在 oder 公司检查并购买新的托管计划,或者如果您无法查看有关 ftp/ajax/jQuery 的信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-04
      • 2021-03-04
      • 1970-01-01
      相关资源
      最近更新 更多