php http:// 包装器在服务器中被禁用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26281426/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 18:15:27  来源:igfitidea点击:

http:// wrapper is disabled in the server?

phpapache

提问by ftxn

The Error Message:

错误信息:

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

I am getting this error message.

我收到此错误消息。

Including a stylesheet or a jquery file with the absolute path does work out, with this I was looking to include a PHP script with the absolute path.

包含具有绝对路径的样式表或 jquery 文件确实可行,因此我希望包含具有绝对路径的 PHP 脚本。

Here is the code:

这是代码:

<!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>

I was looking to include "upload.php" with the absolute path.

我希望在绝对路径中包含“upload.php”。

When I turn "allow_url_include" to "On" then I still get the same error message. Also I was not sure if that was the issue to begin with.

当我将“allow_url_include”设置为“On”时,我仍然收到相同的错误消息。我也不确定这是否是开始的问题。

Any suggestions what to do here?

有什么建议在这里做什么吗?

回答by sjagr

From the PHP docs on include:

PHP 文档开始include

If "URL include wrappers" are enabled in PHP, you can specify the file to be included using a URL (via HTTP or other supported wrapper - see Supported Protocols and Wrappers for a list of protocols) instead of a local pathname.If the target server interprets the target file as PHP code, variables may be passed to the included file using a URL request string as used with HTTP GET. This is not strictly speaking the same thing as including the file and having it inherit the parent file's variable scope; the script is actually being run on the remote server and the result is then being included into the local script.

如果在 PHP 中启用了“URL 包含包装器”,您可以使用 URL(通过 HTTP 或其他支持的包装器 - 请参阅支持的协议和包装器以获取协议列表)而不是本地路径名来指定要包含的文件。如果目标服务器将目标文件解释为 PHP 代码,则可以使用与 HTTP GET 一起使用的 URL 请求字符串将变量传递给包含的文件。严格来说,这与包含文件并使其继承父文件的变量范围不同;该脚本实际上是在远程服务器上运行的,然后将结果包含到本地脚本中。

By obvious inference, you are supposed to use a local pathname!

通过明显的推断,您应该使用本地路径名!

Change this line

改变这一行

<?php include("http://localhost/ubergallery/multiple_image_upload/upload.php"); ?>

to this

对此

<?php include($_SERVER['DOCUMENT_ROOT']."/ubergallery/multiple_image_upload/upload.php"); ?>

The reason that allow_url_include=Ondoesn't work is because you probably didn't restart your Apache server after changing your php.ini

allow_url_include=On不起作用的原因是因为您可能在更改您的 Apache 服务器后没有重新启动php.ini