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:
1 2 3 | allow_url_fopen = On |
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.
1 2 3 | php_value allow_url_fopen on |
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)