在我的应用程序中,我需要打开一个文件来获取其中的内容。
因为我使用了file_get_contents()
$data = file_get_contents('/var/www/web/application/logs/GP_CONFIG/GPConfig_1_1_142604514158.dat');
但这会导致错误
严重性:警告 - > file_get_contents(/var/www/Web/application/logs/GP_CONFIG/GPConfig_1_1_142604514158.dat)[function.file-get-contents]:无法打开流:没有这样的文件或目录
为什么会出现此错误?如何解决这个问题?
答案 0 :(得分:0)
如果文件确实存在,则可能是权利/所有权问题。
$ chmod 775 /var/www/Web/application/logs/GP_CONFIG/GPConfig_1_1_142604514158.dat
并检查文件的所有权
ls -l /var/www/Web/application/logs/GP_CONFIG/GPConfig_1_1_142604514158.dat
。但实际上,你更有可能在文件名中输入错误