How to Fix File Access Is Disabled in the Server Configuration

I am checking it my link verifier script is working when I have encountered this error.

This is my function that checks if a url is existing.


function ipiel_ping_link($obj) {
$flag = 0;
try {
$handle = fopen($obj, "r");

if (!$handle) {
$flag = 0;
} else {
$flag = 1;
fclose($handle);
}
} catch(Exception $e) {
$flag = 0;
}
return $flag;
}


But, it always return the above error. I tested locally and found out that it's working.

Problem: Most web hosting company have strict default value for php setting. Example: allow_url_fopen is default to off. Which is why I have the mentioned error.

Solution:
Create a php.ini in your root directory and just add this line:

[ini]
allow_url_fopen = 1
[/ini]

This will enable file-access.

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post
NERV Open Source

Building production Spring Boot systems?

Explore NERV — open-source Java libraries for audit trails, persistence, exception handling, and reliable event-driven architecture.

Explore NERV on GitHub →