Back to Top

How to access Remote File using PHP

The light had gone to my office yesterday so I utilize my time.I just pick up my mobile and was started writing an article.

Before few days, I was working in one site which is in WordPress and I want to fetch twitter latest tweet and I have used one of the plugins in WordPress to fetch twitter latest tweets and what happened is tweets fetched in local but it was not loading on live server.

After that, I have debugged code and found that allow_url_fopen function is used to fetch tweets from twitter and allow_url_fopen function is off in live web server. Mostly this PHP parameter allow_url_fopen has been disabled by default on live server and that means that once allow_url_fopen is set as off, your application cannot retrieve remote files at all.

If allow_url_fopen is off, can’t retrieve remote files or remote URL in PHP.The open() function and the include and require directives can retrieve remote files if allow_url_fopen is on and we can set this by php.ini or by .htaccess.

To open remote files with fopen() is implemented by a PHP feature called the URL fopen wrapper. It’s enabled by default but if it’s disabled by setting allow_url_fopen to off. If you can’t open/access remote files with fopen(), check your server configuration.

1) PHP.INI METHOD

If you have an access of php.ini file then you just need to place the below code in your php.ini file or replace the existing parameters with below one:

2) .HTACCESS METHOD

Now if you don’t have an access to your php.ini then you can change these parameters from the .htaccess file as well. copy below code in your .htaccess file and you are ready to go.

Here are the couple of articles which you should definitely read

To change File/Image Upload Path in WordPress
change the file ownership Ubuntu
To Create a Temporary File in PHP

I hope you have enjoyed this article. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Comments (2)

  1. Hi there

    Thanks your articles are really informative. Thank you

  2. Iˇm now not certain the place you’re getting your info, however good topic. I must spend some time finding out more or figuring out more. Thanks for wonderful info I was on the lookout for this info for my mission.

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular Posts

How to move Modx site to Live server

Posted on 5 years ago

Bhumi

Really! PHP touches the 200 Million Mark

Posted on 5 years ago

John Pitt

Introduction to Table Partitioning in Oracle

Posted on 10 months ago

Bhumi

How To Store Binary Data in PHP

Posted on 6 years ago

Bhumi

Overview of ECMAScript 6 new Features

Updated 18 years ago

Bhumi

Getting started with Amazon Web Services

Updated 18 years ago

Bhumi

Facade implementation in Laravel

Updated 18 years ago

Bhumi

The Reader’s Poll – June 2015

Posted on 2 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 3 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 4 years ago

Bhumi