• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1206
  • Last Modified:

file_get_contents on windows

PHP Warning:  file_get_contents(http://website.com/file.php): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error

do I have to change the permission of file.php
1 Solution
Normally a permission error will result in a "403 permission denied" http headder coming back.
500 server error, means exactly that, there was an error on the server while executing the code in the url that you requested.

It doesn't however mean that the server didn't return anything at all... the 500 header may have been generated by the script itself, and some content was still send back.

The only way to test this is to view the returned contents. Try opening the url in a browser, this may give you some more information. If the server is blocking the details of the error from being sent back to you, you may get more information from the PHP error logs on the server itself.

Without knowing what you are expecting in return or the actual URL itself, this is about the best place to start your analysis.

Hope this helps.
Some system will fail to get the content if you are reading content from the same domain where your script is located.  So trying giving the physical path directly if the domain is same.

Also, check if "allow_url_fopen" directives is enabled in your PHP.INI file.  

You can also trying changing the permission.

Its not finding file or you have an error in apqche either configuration or due to your code
Ray PaseurCommented:
failed to open stream probably means that you got nothing at all except the headers indicating the failure on the remote server.  You can test for this - file_get_contents() returns a value which is documented on the PHP.net web site.  You may find that CURL gives you a better collection of diagnostics, since file_get_contents() is pretty much a pass/fail function.

My guess is that there is a configuration error or similar problem on the remote server.
rgb192Author Commented:
best answer due to a better suggestion (curl).  Thanks

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now