PHP symlink():可写文件夹中的权限被拒绝

发布于 2024-10-06 15:19:37 字数 392 浏览 0 评论 0原文

我想用 PHP 创建一个符号链接。

符号链接需要与上传的文件放在同一位置,这应该没问题吧?

我真正的问题是,当使用 symlink() 时,我在 PHP 可以从 $_FILES 写入的同一目录上收到权限被拒绝错误。

我使用 text.txt 作为测试文件,使用 link 作为符号链接进行了测试:

symlink("repository/text.txt", "link" );

PHP 脚本从 content/folder/script.php 运行。我在这里做错了什么?符号链接是否需要文件扩展名(我对此表示怀疑)或其他什么?

I want to create a symlink with PHP.

The symlink needs to go in the same place as the uploaded file, which should be fine right?

My real problem is that when using symlink(), I get a permission denied error on the same directory that PHP can write to from $_FILES.

I have done a test using text.txt as the test file, and link as the symlink:

symlink("repository/text.txt", "link");

The PHP script is run from content/folder/script.php. What am I doing wrong here? Do symlinks need file extensions (I doubt it) or something?

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

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

发布评论

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

评论(1

暖树树初阳… 2024-10-13 15:19:37

如果这是您正在使用的代码

symlink("repository/text.txt", "link");

并且您的脚本作为 /var/www/scripts/script.php 运行,则符号链接将在脚本运行的目录中创建。

尝试使用绝对路径。

If this is the code you're using

symlink("repository/text.txt", "link");

And your script runs as /var/www/scripts/script.php the symlink will be created in the directory the script runs in.

Try using an absolute path.

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