为什么file_put_contents拒绝为以下代码工作?
$f = file_put_contents("files/r.js", "Some text here");
if ($f) print 1;
else print 0;
Run Code Online (Sandbox Code Playgroud) 在我完成设置LAMP并安装了我的laravel 4应用程序后,我遇到了问题.一切似乎进展顺利,当我继续我的IP地址网址时,它正确显示我的应用程序的第一页,但页面的其余部分都给我一个404错误在此服务器上找不到请求的URL.
所以我添加到我的httpd.conf(在我的项目的虚拟主机下) - AllowOverride All Order允许,拒绝
<VirtualHost *:80>
ServerName VPS-IP-ADDRESS
DocumentRoot /var/www/html/nextmatch/public_html/public/
<Directory /var/www/html/nextmatch/public_html/public/>
AllowOverride all
Order allow,deny
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试导航而不是404错误我得到了禁止您没有权限访问此服务器.我设置了chmod 775 -R path/laravel/和777的文件夹存储,但我仍然得到相同的错误任何建议,请?我无法弄清楚这个问题我疯了!感谢您的任何帮助.
保存不存在的文件时的问题文件权限,最初创建为新文件.
现在,一切顺利,保存的文件似乎有模式644.
我需要在这里更改什么才能使文件保存为模式777?
万分感谢任何提示,线索或答案.我认为与此相关的代码包括:
/* write to file */
self::writeFileContent($path, $value);
/* Write content to file
* @param string $file Save content to wich file
* @param string $content String that needs to be written to the file
* @return bool
*/
private function writeFileContent($file, $content){
$fp = fopen($file, 'w');
fwrite($fp, $content);
fclose($fp);
return true;
}
Run Code Online (Sandbox Code Playgroud) 通常,我尝试将我的文件夹设置为拥有权限775,但是某些web主机拒绝让PHP写入或将文件移动到任何文件夹,除非它具有权限777(可能是open_dir或安全模式).
有没有办法防止从这些文件夹中运行任何PHP文件,以防恶意PHP脚本上传到那里?