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

    <tfoot id='I9giO'></tfoot>

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

      file_put_contents 未创建 txt 文件

      时间:2024-04-13
        <tbody id='neFPf'></tbody>
    2. <legend id='neFPf'><style id='neFPf'><dir id='neFPf'><q id='neFPf'></q></dir></style></legend>

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

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

            • <tfoot id='neFPf'></tfoot>
              1. 本文介绍了file_put_contents 未创建 txt 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我目前有一个 php 脚本,它在浏览器浏览器浏览网页时运行.我要做的是在脚本运行时编写一个文本文件来存储变量.该文件夹的所有者是apache,但每个人都有读写权限,严格用于测试目的.(我认为这可能是权限问题)在服务器上启用了 SELINUX,当我从控制台运行脚本时,它会在正确的目录中创建文本文件.

                I currently have a php script that is running when a browser browser browses to the webpage. What I'm trying to do is write a text file when the script runs that stores a variable. The owner of the folder is apache, but everyone has read write, strictly for testing purposes. (I thought it might be a permissions issue) SELINUX is enabled on the server, and when I run the script from console it creates the text file just fine, and in the right directory.

                file_put_contents("My working file location", $myString);
                

                我正在使用这一行来尝试编写和创建文本文件,我知道我的文件位置有效,因为我可以运行它并在离线模式下创建它,即通过控制台运行它.问题是我试图写入的变量是通过 HTTP Post 填充的,当我通过浏览器运行脚本时,或者当 apache 运行脚本时,它不会写入或创建文件.我需要做些什么来允许访问写入/更改语法明智地让这个脚本写入这个文本文件?

                I'm using this line to try to write and create the text file, I know that my file location works becaus I can run it and create it in offline mode, I.E. running it through console. The problem is that the variable I'm trying to write is populated through HTTP Post, and when I run the script through the browser, or when apache runs the script, it does not write or create the file. What do I need to do to allow access to write/change syntax wise to get this script to write this text file?

                推荐答案

                您的问题可能是由于 apache 没有权限写入您指定的文件位置.转到该目录并使用 ls 命令检查权限和组所有权:

                Your problem is likely due to apache not having permissions to write to the file location you specified. Go to that directory and check the permissions and group ownership with the ls command:

                cd "My working file location"
                ls -l .
                

                输出中有三列显示目录的权限、所有者和组.它们很可能归 root 所有,并且没有 apache 写入目录的权限.

                There are three columns in the output that show the permissions, owner, and group for the directory. Most likely they are owned by root and don't have permissions for apache to write to the directory.

                如果是这种情况,那么当 apache 尝试创建文件时,您会在 apache 日志中看到一个错误.在浏览器中运行脚本时尝试跟踪日志:

                If this is the case, then you will see an error appear in your apache log when it tries to create the file. Try tailing your logs while running the script in your browser:

                tail -f /var/log/apache2/error.log
                

                这篇关于file_put_contents 未创建 txt 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:高负载下的 502 网关错误 (nginx/php-fpm) 下一篇:如何找出 cURL 挂起且无响应的原因?

                相关文章

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

                      <bdo id='5xaxu'></bdo><ul id='5xaxu'></ul>

                    <small id='5xaxu'></small><noframes id='5xaxu'>

                  1. <legend id='5xaxu'><style id='5xaxu'><dir id='5xaxu'><q id='5xaxu'></q></dir></style></legend>

                    <tfoot id='5xaxu'></tfoot>