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 = ‘’;
$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.


Add a Comment

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