CodeIgniter Forums
how can i use fopen() with CodeIgniter? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: how can i use fopen() with CodeIgniter? (/showthread.php?tid=31298)



how can i use fopen() with CodeIgniter? - El Forum - 06-14-2010

[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!


how can i use fopen() with CodeIgniter? - El Forum - 06-14-2010

[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.


how can i use fopen() with CodeIgniter? - El Forum - 06-14-2010

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


how can i use fopen() with CodeIgniter? - El Forum - 06-14-2010

[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


how can i use fopen() with CodeIgniter? - El Forum - 06-14-2010

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


how can i use fopen() with CodeIgniter? - El Forum - 06-15-2010

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

InsiteFX