Jump to content

File_Get_Contents() Issue On Stevie


wolstech

Recommended Posts

PHP's file_get_contents() isn't working properly on Stevie. It's been working fine since I started hosting here, but just stopped yesterday. If I use file_get_contents() to retrieve something else that's on my own domain, it fails. It works fine if I request something not located on my domain, such as Google's website.

 

file_get_contents("http://raxsoft.tk/raxdev/sbt/sb.php?b=105");

That code should return an image, but instead returns false. A request where the target is on my own domain will fail. If you view the targeted URL in a browser, it loads fine, so the resource isn't the problem. This exact command worked yesterday, but now fails for an unknown reason.

 

file_get_contents("http://google.com") returns HTML for google as expected.

 

Here's a test script that shows the issue: http://raxsoft.tk/ra...sbt/testget.php If it works, you'll see an American flag with a countdown to July 4th next year. If it fails, it'll say so.

 

Anyone have an idea why this is happening? (raxsoft.tk, user rax on Stevie)

Link to comment
Share on other sites

This would never return an image:

 

file_get_contents("http://raxsoft.tk/raxdev/sbt/sb.php?b=105");

 

It would try to return the contents. Evidently your browser was interpreting the source as the image.

Don't forget you need to echo it out:

 

<?php
$src = file_get_contents("http://raxsoft.tk/raxdev/sbt/sb.php?b=105");
echo $src;
?>

 

I just tried a couple of tests on my site and it was working fine.

 

 

Link to comment
Share on other sites

Well yes. I meant the contents of an image (binary data). It is echoed out. My test script is like yours, except it has an if statement to check that $src has data and not false in it. The problem is in my case the image content is never read. In your example code, $src is false(meaning the get failed) instead of the image data once the file_get_contents runs. Echoing false doesn't do anything useful...

 

I'll try a few other things, but I'm stumped as to why this just quit working on Friday...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...