错误讯息:
Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\ubergallery\multiple_image_upload\multiupload.php on line 27
Warning: include(http://localhost/ubergallery/multiple_image_upload/upload.php): failed to open stream: no suitable wrapper could be found in C:\xampp\htdocs\ubergallery\multiple_image_upload\multiupload.php on line 27
Warning: include(): Failed opening 'http://localhost/ubergallery/multiple_image_upload/upload.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\ubergallery\multiple_image_upload\multiupload.php on line 27
我收到此错误消息。
包含带有绝对路径的样式表或jquery文件确实有效,我希望包含一个带有绝对路径的PHP脚本。
以下是代码:
<!DOCTYPE html>
<html>
<head>
<title>Upload Multiple Images Using jquery and PHP</title>
<!-------Including jQuery from google------>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="script.js"></script>
<!-------Including CSS File------>
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<div id="maindiv">
<div id="formdiv">
<h2>Multiple Image Upload Form</h2>
<form enctype="multipart/form-data" action="" method="post">
First Field is Compulsory. Only JPEG,PNG,JPG Type Image Uploaded. Image Size Should Be Less Than 100KB.
<hr/>
<div id="filediv"><input name="file[]" type="file" id="file"/></div><br/>
<input type="button" id="add_more" class="upload" value="Add More Files"/>
<input type="submit" value="Upload File" name="submit" id="upload" class="upload"/>
</form>
<br/>
<br/>
<!-------Including PHP Script here------>
<?php include("http://localhost/ubergallery/multiple_image_upload/upload.php"); ?>
</div>
<!-- Right side div -->
<div id="formget"><a href=http://www.formget.com/app><img src="formget.jpg" alt="Online Form Builder"/></a>
</div>
</div>
</body>
</html>
我希望包含&#34; upload.php&#34;绝对的道路。
当我转过&#34; allow_url_include&#34;到&#34;开&#34;然后我仍然得到相同的错误消息。此外,我不确定这是否是问题的开始。
有什么建议吗?
答案 0 :(得分:11)
如果在PHP中启用了“URL include wrappers”,则可以使用URL指定要包含的文件(通过HTTP或其他受支持的包装器 - 请参阅支持的协议和包装器以获取协议列表)而不是本地路径名。如果目标服务器将目标文件解释为PHP代码,则可以使用与HTTP GET一起使用的URL请求字符串将变量传递给包含的文件。严格来说,这与包含文件并使其继承父文件的变量范围完全相同;该脚本实际上正在远程服务器上运行,然后结果将包含在本地脚本中。
通过明显的推断,你应该使用本地路径名!
更改此行
<?php include("http://localhost/ubergallery/multiple_image_upload/upload.php"); ?>
到这个
<?php include($_SERVER['DOCUMENT_ROOT']."/ubergallery/multiple_image_upload/upload.php"); ?>
allow_url_include=On
不起作用的原因是因为您在更改php.ini
后可能没有重启Apache服务器