file_get_contents on windows

Posted on 2011-05-11
Last Modified: 2013-12-13
PHP Warning:  file_get_contents( failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error

do I have to change the permission of file.php
Question by:rgb192
    LVL 3

    Expert Comment

    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.
    LVL 5

    Expert Comment

    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.

    LVL 11

    Expert Comment

    Its not finding file or you have an error in apqche either configuration or due to your code
    LVL 107

    Accepted Solution

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

    Author Closing Comment

    best answer due to a better suggestion (curl).  Thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Redirected folders in a windows domain can be quite useful for a number of reasons, one of them being that with redirected application data, you can give users more seamless experience when logging into different workstations.  For example, if a use…
    New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
    This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
    This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now