Php fopen()有效,dio#u open()无效';T
看到一些问题运行时,工作正常。这是我写的一个测试脚本,用于检查这个问题,因为它出现在我正在尝试工作的新安装中Php fopen()有效,dio#u open()无效';T,php,file,fopen,Php,File,Fopen,看到一些问题运行时,工作正常。这是我写的一个测试脚本,用于检查这个问题,因为它出现在我正在尝试工作的新安装中 <?php echo "Current User: " . get_current_user() . "<br/>"; echo "UID: " . getmyuid() . "<br/>"; echo "GID: " . getmygid() . "<br/>"; echo "&l
<?php
echo "Current User: " . get_current_user() . "<br/>";
echo "UID: " . getmyuid() . "<br/>";
echo "GID: " . getmygid() . "<br/>";
echo "<br/>";
$foTest = fopen("test.txt","r");
echo fread($foTest,4);
$fd = dio_open('test.txt', O_RDONLY);
$read = dio_read($fd);
echo $read;
$file = dio_open('test.txt', O_WRONLY | O_CREAT);
?>
我整晚都在为这件事挠头,从我的发现中几乎没有任何关于dio的文档。很少有人说这里需要什么。我唯一能想到的是suExec,但目前没有任何指令会导致这种情况,尽管如果是这样的话,这些指令肯定也会对fopen失败
这里的任何帮助都将不胜感激 首先确保您的文件存在。 此外,您的php文件权限应为0777以创建文件 您可以通过此命令自动添加文件夹以设置权限“777”
$folder=mkdir( "yourdirname", 0777);
然后你应该试着去理解这个问题
$file="test.txt";
//maybe your server cannot find the root
// if it does not solve the problem write root file command
// $file=dirname(__FILE__).DIRECTORY_SEPARATOR."test.txt";
if (file_exists($file)) {
//its ok try to continue
} else {
echo "the text file is not exits !";
}
我认为米奇和艾哈迈特在正确的轨道上 尝试
dio\u打开(uuuu DIR\uuuu.DIRECTORY\u分隔符.'test.txt',…)
至少在这种情况下,dio_open
不试图构造绝对路径。filename
参数将不加更改地传递给操作系统
没有这样的文件或目录
和权限被拒绝
错误来自操作系统,而不是dio库。因此,您的服务器可能在错误的位置查找test.txt
。是否可能dio_open不读取相对路径?如果您使用完全限定的路径进行尝试,会发生什么?啊!真不敢相信我居然没想到!那正是它的本来面目!dio试图读取文件/test.txt而不是/test.txt。我通过在脚本上完全设置引用文件来测试这一点,然后脚本正确读取文件并输出内容。
$file="test.txt";
//maybe your server cannot find the root
// if it does not solve the problem write root file command
// $file=dirname(__FILE__).DIRECTORY_SEPARATOR."test.txt";
if (file_exists($file)) {
//its ok try to continue
} else {
echo "the text file is not exits !";
}