0
我正在尝试使用单独国家的文本文件逐行列出下拉列表。FilePointer拒绝打开
问题是,无论什么原因,我的文件拒绝打开。
下面的代码:
<?php
$path = realpath(dirname(__FILE__));
require_once('upload.controller.php');
$filePath = $path.'/../includes/_notes/countries.txt';
$handle = fopen($filePath, "r");
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../includes/css/adsmanager.css" />
<script type="text/javascript" src="../includes/js/.."></script>
</head>
<body>
<!--<form method="post" action="upload.controller.php">-->
<!--<select>
<script type="text/javascript" src="includes/js/countries.js" /></script> -->
<?php
if ($handle) {
while(($buffer = fgets($file)) != false) {
var_dump($buffer);
}
if (!feof($handle)) {
die("failed to open file");
}
}
fclose($handle);
?>
<!--</select>
</form>-->
</body>
</html>
与我一起输出:
string(66) "/var/www/patention/modules/upload/../includes/_notes/countries.txt" failed to open file
难道我做错了什么?我从 PHP Manual上直接列出的例子中拿出来。随着this。
是的,我试过,之前可惜没有奏效。这就是为什么我尝试了realpath(dirname(__ FILE__))路径,并将其添加到文件路径。任何其他想法? – zeboidlund
你有什么错误? – xbonez
我没有得到任何错误,这是奇怪的事情。如果feof($ handle)返回false,我只需要一个die语句。 – zeboidlund