View Full Version : file_put_contents() not working in IE9 only

02-17-2012, 06:56 PM
I am trying change a file with name exactly the same as a email address. Just meaning to add a small snippet of text to it via ajax call with jquery .get().

So far it works great in Chrome and FF but IE9 is not working file_put_contents() function only, Ajax fires no problem.

Another oddity is that after doing the file_put_contents() in IE9, I imediatly do a file_get_contents to check if the message was sent successfully. IE9 returns the message I want it to save, but inspecting the file itself shows nothing has changed!?

Here is my code:

$emailFileName = trim($email);

$status = 'new message';

$filePutResult = file_put_contents($emailFileName, $status);

echo $emailFileName.'\'s status has been set to: '.$status.' ...and this many bytes were written to the file: '.$filePutResult.'<br />';

$fileGetResult = file_get_contents($emailFileName);

echo $emailFileName.'\'s status really is: '.$fileGetResult;

Any thoughts? I appreciate the help

02-17-2012, 07:13 PM
php works the same no matter what browser you're using. It's a serverside language, not clientside.

02-17-2012, 07:16 PM
Are you getting any error messages (check server logs if you have access)? How much data is being passed via ajax?

02-17-2012, 08:35 PM
I don't suppose you're looking for the submit button in your code? (like the code sample in my signature)

If you are then you need to read the link in my signature as this is classic IE behaviour not to submit the button and cause scripts not to work as expected.

02-17-2012, 08:36 PM
GET requests are supposed to return the same result from multiple calls so browsers are allowed to cache the result for reuse if the same call is made again. IE is one of the browsers that is more efficient by actually what it is allowed to in that situation.

If you expect the data to change between calls you need to use POST.

That's the main difference between what GET and POST actually do (everything else is cosmetic).