File_get_contents not working

I’m using file_get_contents in a plugin to get an image uploaded by Gravity Forms. It works fine on my live and staging sites by not in Local. I get the following error:

PHP Warning: file_get_contents(https://mylocalsite.test/wp-content/uploads/gravity_forms/blah.jpg): failed to open stream: Connection refused

I’ve checked /conf/php/7.1.4/php.ini and allow_url_fopen is set to On.

Any advice on how I can get this working?

Hey Simon,

Can you try using HTTP instead of HTTPS?

Also, if you need to use HTTPS check this out: cURL error when accessing SSL Local Site

Hi Clay

I discovered it works if I use the file path rather than URL, adding the FILE_USE_INCLUDE_PATH parameter to the call to file_get_contents.