2017-08-15 222 views
1

我需要帮助解决这个错误:Laravel地方:FOPEN权限被拒绝

fopen(/Subckt.txt): failed to open stream: Permission denied

  • 我使用Laravel
  • 我工作的网站在本地使用CMD与PHP 工匠服务命令
  • 我发现了一些与chmod的潜在解决方案,但由于我使用本地主机,我不认为它的工作
  • 该网站正在运行一个PHP代码来修改一个txt文件。然后我将它保存到另一个文件。在根文件夹中。
  • 整个网站文件夹被声明为只读,我无法修改该文件夹。 (我使用Windows 7,当我取消选中它总是重新检查框,但我设法删除只读文本文件(Subckt.txt和\ npn.lib)
  • 我试着我的代码没有laravel在。PHP和HTML文件,它的工作原理

这里是我的部分代码:。

// 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); 
+1

检查你的'基路径'。 'fopen'函数似乎试图从文件系统的根目录加载文件,这肯定会产生权限冲突。 – Ohgodwhy

+0

In:$ inputFile =“\ npn.lib”; \ n被认为是新行... – Mark

+0

$ inputFileContent = file_get_contents(“C:\ Users \ username \ Desktop \ model \\ testnpn.lib”);而不是2行 – Mark

回答

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。在窗户上,我不知道...我希望我可以帮助一些。