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

[eluser]chengfeng[/eluser]
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:
---------------------

$filename="http://www.example.com/text.txt";
$file=fopen($filename,"r");

-----------------------
Thank you indeed!
#2

[eluser]WanWizard[/eluser]
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.
#3

[eluser]chengfeng[/eluser]
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!
--------------------
$filename="http://www.example.com/text.txt";
$file = fopen($filename,"r");
echo fread($file,100);
fclose($file);
--------------------
#4

[eluser]Ivar89[/eluser]
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
#5

[eluser]chengfeng[/eluser]
what is rewrite error?
#6

[eluser]InsiteFX[/eluser]
what is rewrite error? = SEARCH!

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB