test.php 无法将文件输出到 Leopard 文件系统中

发布于 2024-08-04 23:44:28 字数 529 浏览 12 评论 0原文

我可以知道我需要添加什么权限,以允许 test.php 能够将文件写入 macos 文件系统

PHP Error: <br />
<b>Warning</b>:  file_put_contents(20090915203127.jpg) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: Permission denied in <b>/Library/WebServer/Documents/testphp/test.php</b> on line <b>8</b><br />
ERROR: Failed to write data to 20090915203127.jpg, check permissions

这是我在 leopard 上遇到的错误,我已经 chmod ugo+x for test.php

may i know what permission do i need to add, to allow test.php to able to write file into macos filesystem

PHP Error: <br />
<b>Warning</b>:  file_put_contents(20090915203127.jpg) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: Permission denied in <b>/Library/WebServer/Documents/testphp/test.php</b> on line <b>8</b><br />
ERROR: Failed to write data to 20090915203127.jpg, check permissions

this is the error i get on leopard, i already chmod ugo+x for test.php

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夜唯美灬不弃 2024-08-11 23:44:28

需要权限的不是文件,而是运行 PHP 的进程。假设您在默认状态下使用 (Snow) Leopard,您需要授予 _www 用户对给定目录的写入权限,授予全世界写入权限(一个不太令人愉快的想法)。这两者都可以通过 chown 和 chmod 的组合来完成。

It's not the file that needs permissions, it's the process running PHP. Assuming you're using (Snow) Leopard in it's default state, you'll need to give the _www user write permissions to the given directory, or give the world write access (a less savoury idea). Both of these can be accomplished with a combination of chown and chmod.

柳若烟 2024-08-11 23:44:28

您需要确保运行脚本的用户有权写入尝试写入的文件(即 20090915203127.jpg,而不是 PHP 脚本)。如果20090915203127.jpg不存在,您需要确保该文件所在的目录是可写的(默认情况下这将是当前的工作目录)。

您可能需要阅读chmod

You need to make sure the user the script is running under is allowed to write to the file trying to write to (i.e. 20090915203127.jpg, not the PHP script). If 20090915203127.jpg does not exist, you'll need to make sure the directory that file's going to is writable (by default this will be the present working directory).

You may need to read about chmod.

筱果果 2024-08-11 23:44:28

据我所知,您需要 root 权限才能直接写入 /Library。是否绝对有必要写入该目录?

如果您只是将文件写入您自己的帐户,那么在 /Users/accountname 下它应该可以工作(尽管这取决于正在执行 php 脚本的用户)。

As far as I know you need root rights to be able to write directly to /Library. Is it absolutely necessary to write to this directory?

If you just write files to your own account, under /Users/accountname it should work (although that depends on the user who is executing the php script).

初见 2024-08-11 23:44:28

您需要使目标文件/目录可写入 Web 服务器。 test.php 不感兴趣...

You need to make the target file / directory writable to the web server. test.php is not into that...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文