Welcome Guest, Not a member yet? Register   Sign In
how can i use fopen() with CodeIgniter?

Hi, i am trying to open text file via URL, but the error occurred,it said:
Message: fopen(http://www.example.com/text.txt) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
What should i do? Please help!
Note that if i use fopen() without CI , it's worked, no error occurred. Just simple code.
The code is:


Thank you indeed!

This has nothing to do with CI, the webserver is returning an error code.

I find it hard to believe that if you put those two lines in a stand-alone PHP script it works, and from a CI application it doesn't.

Or do you mean that 'www.example.com' is a CI application? You're not very clear on that. In that case, error 500 is probably a rewrite error.

Thanks for your comment! I have 2 websites. I want to use the second project(CI) to read a text file from the first project. When i use fopen() with CI, it doesn't work and so the error above. Then i test my code by copy it and write as stand-alone PHP script, It can be open and echo any text from the text file. These 2 websites are different hosting.
Sorry for bad English. And please tell me if you don't understand. Please!
$file = fopen($filename,"r");
echo fread($file,100);

500 is a server error and has nothing to do with CI, like Wizard said: rewrite error.
also use [ code][/ code] tags for your code no _____ Wink

what is rewrite error?

what is rewrite error? = SEARCH!


Theme © iAndrew 2016 - Forum software by © MyBB