ftxn
ftxn

Reputation: 143

http:// wrapper is disabled in the server?

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.

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.

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.

Any suggestions what to do here?

Upvotes: 5

Views: 38988

Answers (1)

sjagr
sjagr

Reputation: 16502

From the PHP docs on 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.

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=On doesn't work is because you probably didn't restart your Apache server after changing your php.ini

Upvotes: 19

Related Questions