file_put_contents not creating txt file

前端 未结 6 764
后悔当初
后悔当初 2020-12-17 21:28

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 v

6条回答
  •  伪装坚强ぢ
    2020-12-17 21:50

    Something else to try, for people with a similar question. You might just be making a simple mistake that doesn't require you to mess around with the file permissions—and if you're making this mistake, fixing the file permissions might not help.

    Be sure you're using a local, relative file path in file_put_contents().

    For example, use:

    file_put_contents('short_local_path/my_working_file.txt', $myString);
    

    Not:

    file_put_contents('http://example.com/remote_path/my_working_file.txt', $myString);
    

    And not:

    file_put_contents('/whole/root/file/path/to/my_working_file.txt', $myString);
    

提交回复
热议问题