fopen() works, dio_open() doesn't?

时间:2015-05-12 22:55:38

标签: php file fopen

Seeing some issues running fopen() when dio_open() is working just fine. Here's a test script I wrote to check the issue as it was appearing in a new installation I'm trying to get working.

            default:
                running = true;
            }
        break; <--- inserted
        case SDL_QUIT:

The script outputs the following:

Current User: infinitywhack UID: 1004 GID: 1002

test Warning: dio_open(): cannot open file test.txt with flags 0 and permissions 0: No such file or directory in /var/www/infinity.whacknet.com/public_html/test.php on line 9

Warning: dio_read() expects parameter 1 to be resource, boolean given in /var/www/infinity.whacknet.com/public_html/test.php on line 10

Warning: dio_open(): cannot open file test.txt with flags 65 and permissions 0: Permission denied in /var/www/infinity.whacknet.com/public_html/test.php on line 12

This shows the user and group (infinitywhack:www) which is correct. The "test" output here is the content of the test.txt file, that is the code that is running with fopen(). The errors are only given by dio functions.

Here are the permissions for both files:

<?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);
?>

I've been scratching my head all night on this one, there's very little documentation on anything dio from what I have found. Very little saying what is needed here. The only thing I could think of was suExec but there aren't any directives in use that would cause this, although surely those same directives would fail for fopen as well if that were the case?

Any help here would be much appreciated!

2 个答案:

答案 0 :(得分:0)

我认为STLMikey&amp;艾哈迈德走在正确的轨道上。

尝试dio_open(__DIR__ . DIRECTORY_SEPARATOR . 'test.txt', ...)

至少在source code dio_open中,filename不会尝试构造绝对路径。 No such file or directory参数将保持不变地传递给操作系统。

Permission denied&amp; test.txt错误来自操作系统,而不是二恶英库。因此,您的服务器似乎可能在错误的位置寻找Arg, there was an API error : 400 : Invalid value 'users::condition::dateOfSession==2015-04-30;ga:sessionCount==1;condition::ga:campaign=@33100;sessions::condition::ga:userType=@Returning Visitor' for segment parameter.

答案 1 :(得分:-1)

firsty make sure your file is exist. Also your php file permissions should be 0777 to create file and you can add a folder to set permission "777" automaticly by this command

vagrant box add default-ubuntu-1204 http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04-i386_chef-provisionerless.box

And than you should try to understand the problem

$folder=mkdir( "yourdirname", 0777);