Solved : fopen and fread not working with url in php

Many times we normally face problems while reading a file using url. Due to wrong PHP configuration we are facing fopen and fread not working with url issue.

fopen and fread not working with url

Using following solution we can easily fix this PHP issue.
For e.g :
$url = ‘http://somesite.com/somefile.txt’;
$fp = fopen($url,”r”);

To allow the fopen to get the contents of the file through url, do the following settings in php.ini file :

allow_url_include = On

By setting above 2 directives to ‘On’, fopen will be able to read the contents from url.

If you are using wamp than we can change this setting by on clicking on wamp icon and than go to PHP and click on setting > and allow_url_fopen option setting.

For linux users, you need to change /etc/php.ini file and do not forget to restart to apache server.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

2 thoughts on “Solved : fopen and fread not working with url in php”

Leave a Reply to prasanth Cancel reply

Your email address will not be published.