0

I am using file_get_contents in my site xyz.com to get an image in demo.com but it return an error:

Warning: file_get_contents(http://demo.com/wp-content/uploads/2016/11/2-1.jpg): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/xyz.com/public_html/core_functions.php on line 113

That file http://demo.com/wp-content/uploads/2016/11/2-1.jpg is exist. But file_get_contents warning it 404.

SteffenCH
  • 154
  • 11
Unnamed
  • 13
  • 5
  • demo.com is a custom record in your hosts file? if so, try to restart apache and clear dns cache – Jakub Trzciński Nov 28 '16 at 08:13
  • i was test again with another link, only link in demo.com is 404. Please tell my why? – Unnamed Nov 28 '16 at 08:20
  • I had the same problem which i fixed by enabling Output_buffering on the server http://php.net/manual/en/outcontrol.configuration.php#ini.output-buffering Which can be enabled in php.ini – SteffenCH Nov 28 '16 at 08:21
  • Please let us know if it helps. – SteffenCH Nov 28 '16 at 08:43
  • Not working for me, thanks – Unnamed Nov 28 '16 at 10:54
  • Possible duplicate of [PHP file\_get\_contents() returns "failed to open stream: HTTP request failed!"](https://stackoverflow.com/questions/697472/php-file-get-contents-returns-failed-to-open-stream-http-request-failed) – Amaan Iqbal Jul 03 '17 at 05:12

0 Answers0