file_get_contents() not working in IE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dimxasnewfrozen
Forum Commoner
Posts: 84
Joined: Fri Oct 30, 2009 1:21 pm

file_get_contents() not working in IE

Post by dimxasnewfrozen »

I have the following script:

Code: Select all

<?php 
$file 	= $_GET["selected_file"];
$filestring =  file_get_contents($file);
$filearray = explode("<br/>", $filestring);

    while (list($var, $val) = each($filearray)) {
        ++$var;
        $val = trim($val);
        print "Line $var: $val<br />";
    }

?>
This works wonderfully in firefox but displays nothing in IE. Is there a known issue with IE or is there something wrong with the script?
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: file_get_contents() not working in IE

Post by flying_circus »

PHP methods are not affected by the client browser. They are all run on the server side and do not care who or what requested the data.

Try outputting the value of $_GET['selected_file'] to make sure the values are identical on both IE and firefox. You should also check for file existence before accessing the file, try using file_exists(). You should also validate your input, preferably a white list of allowed files, else you might find your program is misused.
dimxasnewfrozen
Forum Commoner
Posts: 84
Joined: Fri Oct 30, 2009 1:21 pm

Re: file_get_contents() not working in IE

Post by dimxasnewfrozen »

Right. I'm not worried about the security aspect of it yet.

It's actually bombing out on an ajax call I'm making (client side). I'm sending the contents of the file to a html textarea box which won't properly display in IE.

I'm not sure why IE is so picking when it comes to ajax/php calls.
Post Reply