gpt4 book ai didi

php - file_put_contents 无法在包含路径中创建文件

转载 作者:可可西里 更新时间:2023-10-31 22:53:58 34 4
gpt4 key购买 nike

我正在尝试在桌面上创建一个文本文件。我使用 set_include_path() 创建了一个包含路径,但该文件是在我的 xampp/htdocs 文件夹中创建的。我如何在我的桌面上创建该文件夹??这可能吗??

set_include_path(',;c:/users/shimantta/Desktop');

echo file_put_contents("/test.txt","Hello World. Testing!",FILE_USE_INCLUDE_PATH);

最佳答案

包含路径是 PHP 在包含/需要文件时搜索的路径,而不是在写入文件时搜索的路径。

include_path Specifies a list of directories where the require, include, fopen(), file(), readfile() and file_get_contents() functions look for files.

给出完整路径即可:

file_put_contents("c:/users/shimantta/Desktop/test.txt", "Hello World. Testing!");

这仅在运行脚本的用户或运行网络服务器的用户有权写入该目录时才有效。

关于php - file_put_contents 无法在包含路径中创建文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28547817/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com