欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

php URL file-access is disabled in the server configuration

shiping1 的头像
 

错误提示「URL file-access is disabled in the server configuration」解决方案

分类: 系统运维 320人阅读 评论(0) 收藏 举报

如果您使用 PHP 程序码片段,结果网页上出现「URL file-access is disabled in the server configuration」错误信息,

必须请网站管理员或主机供应商启用 PHP 服务器(php.ini)设定的 allow_url_fopen 和 allow_url_include 选项。

# vi /usr/local/php/etc/php.ini

;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Fopen wrappers ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On

; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
allow_url_include = On

 

如上所示将 allow_url_fopen 和 allow_url_include 两个函数默认的'Off'改为'On'即可。

来自 http://blog.csdn.net/kelonsen/article/details/9023123

 

(下面的这种说法好像不对)
php URL file-access is disabled in the server configuration
 
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://garygang.blog.51cto.com/1472362/1052109

  升级到php5.2.3后,使用include()包含外部文件,会出现错误:URL file-access is disabled in the server configuration….

解决办法:修改php.ini,allow_url_include = On ,

然后重启web服务器。

再刷新看看,ok !

但是这对网站安全性会照成危害。

最好还是使用curl代码 

<?php

/* 

* @return string 

* @param string $url 

* @desc Return string content from a remote file 

* @author Luiz Miguel Axcar (lmaxcar@yahoo.com.br

*/ 

function get_content($url) 



$ch = curl_init(); 

curl_setopt ($ch, CURLOPT_URL, $url);

curl_setopt ($ch, CURLOPT_HEADER, 0); 

ob_start(); 

curl_exec ($ch); 

curl_close ($ch); 

$string = ob_get_contents();

ob_end_clean(); 

return $string; 



#usage: 

$content = get_content ("http://www.php.net");

var_dump ($content); 

?>

本文出自 “蔚蓝” 博客,请务必保留此出处http://garygang.blog.51cto.com/1472362/1052109

来自 http://garygang.blog.51cto.com/1472362/1052109
普通分类: