<tfoot id='CVcjf'></tfoot>

        <bdo id='CVcjf'></bdo><ul id='CVcjf'></ul>
    1. <i id='CVcjf'><tr id='CVcjf'><dt id='CVcjf'><q id='CVcjf'><span id='CVcjf'><b id='CVcjf'><form id='CVcjf'><ins id='CVcjf'></ins><ul id='CVcjf'></ul><sub id='CVcjf'></sub></form><legend id='CVcjf'></legend><bdo id='CVcjf'><pre id='CVcjf'><center id='CVcjf'></center></pre></bdo></b><th id='CVcjf'></th></span></q></dt></tr></i><div id='CVcjf'><tfoot id='CVcjf'></tfoot><dl id='CVcjf'><fieldset id='CVcjf'></fieldset></dl></div>
        <legend id='CVcjf'><style id='CVcjf'><dir id='CVcjf'><q id='CVcjf'></q></dir></style></legend>

      1. <small id='CVcjf'></small><noframes id='CVcjf'>

        使用 PHP 打开或创建文件时权限被拒绝

        Permission denied when opening or creating files with PHP(使用 PHP 打开或创建文件时权限被拒绝)
          <tfoot id='BUeeU'></tfoot>
              <bdo id='BUeeU'></bdo><ul id='BUeeU'></ul>

              <small id='BUeeU'></small><noframes id='BUeeU'>

            • <i id='BUeeU'><tr id='BUeeU'><dt id='BUeeU'><q id='BUeeU'><span id='BUeeU'><b id='BUeeU'><form id='BUeeU'><ins id='BUeeU'></ins><ul id='BUeeU'></ul><sub id='BUeeU'></sub></form><legend id='BUeeU'></legend><bdo id='BUeeU'><pre id='BUeeU'><center id='BUeeU'></center></pre></bdo></b><th id='BUeeU'></th></span></q></dt></tr></i><div id='BUeeU'><tfoot id='BUeeU'></tfoot><dl id='BUeeU'><fieldset id='BUeeU'></fieldset></dl></div>

              <legend id='BUeeU'><style id='BUeeU'><dir id='BUeeU'><q id='BUeeU'></q></dir></style></legend>

                    <tbody id='BUeeU'></tbody>
                1. 本文介绍了使用 PHP 打开或创建文件时权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我不能用 php 创建文件,因为文件 dosent 获得了许可.我收到此错误:

                  I can't create files with php, because the file dosent got permission for that. I get this error:

                  警告:fopen(test.txt):无法打开流:第 20 行/web/com/example.com/index.php 中的权限被拒绝
                  警告:fwrite() 期望参数 1 是资源,布尔值在第 21 行的/web/com/example.com/index.php 中给出
                  警告:fclose() 期望参数 1 是资源,布尔值在第 22 行的/web/com/example.com/index.php 中给出

                  Warning: fopen(test.txt): failed to open stream: Permission denied in /web/com/example.com/index.php on line 20
                  Warning: fwrite() expects parameter 1 to be resource, boolean given in /web/com/example.com/index.php on line 21
                  Warning: fclose() expects parameter 1 to be resource, boolean given in /web/com/example.com/index.php on line 22

                  这是我使用的代码:

                  <?php
                   $file = fopen("test.txt","w");
                   echo fwrite($file,"Hello World. Testing!");
                   fclose($file);
                   ?> 
                  

                  就这么简单!这是 来自 w3schools 的示例代码.

                  所以我需要帮助来了解如何为文件授予所需的权限.我正在使用 net2ftp FTP Web 应用程序将文件上传到我的网站,如果有必要的话.

                  So I need help to find out how to give the file the needed permissions. I'm uploading files to my site with the net2ftp FTP web application, if it matters.

                  推荐答案

                  您的 PHP 脚本尝试写入的文件夹可能归 root 用户所有.如果您使用默认的 Ubuntu/Apache/PHP 设置,您的 PHP 脚本很可能在 www-data 用户下运行.

                  The folder your PHP script is trying to write to will probably be owned by the root user. Your PHP script is more than likely running under the www-data user if you're using a default Ubuntu/Apache/PHP setup.

                  因此,您需要:

                  chown -R www-data:www-data folder
                  chmod -R g+w folder
                  

                  如果您发现 PHP 在不同于 www-data 的用户下运行,则只需在第一行代码中将用户更改为组.

                  If you find PHP is running under a user that is different from www-data then just change the user a group in the first line of code.

                  PS.将文件夹"更改为您的实际文件夹名称.

                  PS. change "folder" for your actual folder name.

                  这篇关于使用 PHP 打开或创建文件时权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                2. <tfoot id='EGT2p'></tfoot>
                3. <legend id='EGT2p'><style id='EGT2p'><dir id='EGT2p'><q id='EGT2p'></q></dir></style></legend>

                      1. <small id='EGT2p'></small><noframes id='EGT2p'>

                            <tbody id='EGT2p'></tbody>
                          <i id='EGT2p'><tr id='EGT2p'><dt id='EGT2p'><q id='EGT2p'><span id='EGT2p'><b id='EGT2p'><form id='EGT2p'><ins id='EGT2p'></ins><ul id='EGT2p'></ul><sub id='EGT2p'></sub></form><legend id='EGT2p'></legend><bdo id='EGT2p'><pre id='EGT2p'><center id='EGT2p'></center></pre></bdo></b><th id='EGT2p'></th></span></q></dt></tr></i><div id='EGT2p'><tfoot id='EGT2p'></tfoot><dl id='EGT2p'><fieldset id='EGT2p'></fieldset></dl></div>
                          • <bdo id='EGT2p'></bdo><ul id='EGT2p'></ul>