Why file_get_contents is not woking on same domain, but https/facebook.com is success

Website URL

(please specify the URL of the site on which you are experiencing the problem)

Error Message

(file_get_contents(https://tuvi.infinityfreeapp.com/nguoi-dung/pdf-template): Failed to open stream: operation failed)

Other Information

(other information and details relevant to your question)

My file called to (https://tuvi.infinityfreeapp.com/nguoi-dung/pdf-template) is https://tuvi.infinityfreeapp.com/nguoi-dung/xuat-pdf

The remote file include was probably blocked by the security system.

Instead of including http:// everywhere, you don’t add them in PHP scripts. You probably want something like just file.php.

4 Likes

Don’t know what exactly you’re trying to do, but if your website is attempting to generate a PDF file, it is indeed being blocked by the security system, as PDF files are not allowed here:

9 Likes

I think the issue you’re experiencing is caused by this security system:

In short, it will prevent anyone from using file_get_contents to download stuff from your website from anywhere, including our own hosting.

Note that if you just want to read local files from your account, you should use file_get_contents with a local path, instead of a website URL. Reading files directly is much faster and more efficient than pulling them through the web server.

8 Likes

Thank for your answer, I try curl and it’s OK!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.