Search code examples
phphtmlxampp

how to display the image from a specified directory


I put all image in D drive. I run one website with xampp appliaction in C: drive. in my page for display image:

<img src="file:///D:/bea/PRODUCT/LB0064_19112015_160229/11-19-2015%209-47-21%20AM.png" class="img-thumbnail" alt="User Image" style="width: 100px;height: 100px;">

But it not display. how to display image in D driver. Thanks.


Solution

  • In Apache typically you would create an alias that points to the specific folder location in your http.conf file. I've never used or even seen xampp but I guess there would be an equivilent method to do so in xampp?

    Creating an alias in xampp

    Generally one would put all files in the server root but over time you'll have multiple projects and thus duplicates. By using an alias style setup for various folders ( images, javascript, xml etc ) they can be easily accessed from whatever project is running on the webserver at the time.

        Alias /D_images "D:/path/to/images/"
        <Directory "D:/path/to/images">
            Options MultiViews
            AllowOverride None
            Order allow,deny
            Allow from all
        </Directory>
    

    Then, once the server has been restarted, you could access the files contained in the target directory like:

    <img src='/D_images/picture.jpg' />