Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP'访问/etc目录;s fopen命令_Php_Fopen_File Permissions - Fatal编程技术网

使用PHP'访问/etc目录;s fopen命令

使用PHP'访问/etc目录;s fopen命令,php,fopen,file-permissions,Php,Fopen,File Permissions,我需要通过fopen访问一个txt文件,该文件位于/etc/company/lastID.txt,可通过以下脚本访问: $dataFile = "/etc/company/lastID.txt"; $fh = fopen($dataFile, "r"); print_r(error_get_last()); $lastID = fread($fh, filesize($dataFile)); fclose($fh); 我收到的错误是: fopen(/etc/company/lastID.t

我需要通过fopen访问一个txt文件,该文件位于
/etc/company/lastID.txt,可通过以下脚本访问:

$dataFile = "/etc/company/lastID.txt";
$fh = fopen($dataFile, "r");

print_r(error_get_last());

$lastID = fread($fh, filesize($dataFile));
fclose($fh);
我收到的错误是:

fopen(/etc/company/lastID.txt): failed to open stream: No such file or directory
但文件肯定在那里。当我使用
require\u一次调用同一目录中的另一个文件时,它会被无问题地读取,只有当我使用
fopen
时,我似乎才有问题


有什么想法吗?

当您尝试读取/etc/company目录中的另一个文件时会发生什么?此错误表示文件不存在。

您是对的,计算机上的目录结构不正确,需要修改。用鱼打自己