allow_url_fopen not working in server?

筅森魡賤 提交于 2019-12-24 10:37:07

问题


I am using ups service for my project,I have the following code which is working fine in my localhost,

.......
 $fp = fopen($url, "r");    
      while(!feof($fp)){ 
        $result = fgets($fp, 500);
        $result = explode("%", $result);
         //print_obj($result);
        $errcode = substr($result[0], -1);
        switch($errcode){
          case 3:
            $returnval = $result[8];
                break;
          case 4:
            $returnval = $result[8];
            break;
          case 5:
            $returnval = $result[1];
            break;
          case 6:
            $returnval = $result[1];
            break;
        }
      }
      fclose($fp);
.....

But fopen is not working in my server, i checked ini settings allow_url_fopen On has been enabled already. Is there any other settings i missed. Kindly advice on this.


回答1:


In some servers, access to distant url ( outgoing traffic on port ) are disabled by network managers, for security reasons. I saw this problem many times before. It may be for this reason.

If it's the reason and you know what url ( and server IP ) you have to request, you can ask for adding some iptables rules to allow access to that URL.



来源:https://stackoverflow.com/questions/9029951/allow-url-fopen-not-working-in-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!