我需要帮助才能解决此错误:
fopen(/Subckt.txt):无法打开流:权限被拒绝
这是我的部分代码:
// Load the output file
$outputFile = fopen("\Subckt.txt", "w") or die("Unable to open file!");
// Load the input file into string
$inputFile = "\npn.lib";
// Put the input file in a string variable
$inputFileContent = file_get_contents($inputFile);
答案 0 :(得分:0)
对于运行php脚本的用户,您是否拥有该文件的写权限?谁是您尝试fopen
的文件的所有者?也许是www-data用户尝试运行试图打开文件的php脚本,但如果该文件不是由www-data组拥有或者没有全局写权限,则会与php的权限冲突。如果您使用的是Linux,请尝试使用此chown -R www-data:www-data /path/to/the/project/folder
。如果chown
方法不起作用,请尝试使用chmod -R 775 /path/to/the/file
。在Windows上,我不知道......我希望我可以帮助一些。
答案 1 :(得分:-1)
作者:JasonLewis
阅读file_get_contents()。错误是自我解释的。您将资源传递给file_get_contents(),而不是字符串。您需要将其称为:
$contents = file_get_contents("textdoc.txt");
我在那里找到了答案:https://forums.phpfreaks.com/topic/117829-solved-file-get-contents-help/