Image is not showing in browser?

前端 未结 12 1992
一整个雨季
一整个雨季 2020-12-17 03:42

    

Duke\'s soccer League: Home Page

相关标签:
12条回答
  • 2020-12-17 04:21

    If we are using asp.net "FileUpload" control and want to preview image before upload we can use below code.

    <asp:FileUpload ID="fileUpload" runat="server" Style="border: none;" onchange="showpreview(this);" />
    <img id="previewImage" src="C:\fakepath\natureImage.jpg">
    
    
    <script>
        function showpreview(Imagepath) {
            var reader = new FileReader();
            reader.onload = function (e) {
                $("#previewImage").attr("src", e.target.result);
            }
            reader.readAsDataURL(Imagepath.files[0]);
        }
    </script>
    
    0 讨论(0)
  • 2020-12-17 04:22

    do not place *jsp or *html in root folder of webapp and images you want to display in same root folder browser cannot acess the image in WEB-INF folder

    0 讨论(0)
  • 2020-12-17 04:24

    I had a problem where the images would not show and it wasn't the relative path. I even hard coded the actual path and the image still did not show. I had changed my webserver to run on port 8080 and neither

    <img src="c:/public/images/<?php echo $image->filename; ?>" width="100" />
    <img src="c:/public/images/mypic.jpg" width="100" />
    

    would not work.

    <img src="../../images/<?php echo $photo->filename; ?>" width="100" />
    

    Did not work either. This did work :

    <img src="http://localhost:8080/public/images/<?php echo $image->filename; ?>" width="100" />
    
    0 讨论(0)
  • 2020-12-17 04:28

    I don't know where you're running the site from on your computer, but you have an absolute file path to your C drive: C:\Users\VIRK\Desktop\66.jpg

    Try this instead:

    <img  src="[PATH_RELATIVE_TO_ROOT]/66.jpg" width="400" height="400" />
    

    UPDATE:

    I don't know what your $PROJECTHOME is set to. But say for example your site files are located at C:\Users\VIRK\MyWebsite. And let's say your images are in an 'images' folder within your main site, like so: C:\Users\VIRK\MyWebsite\images.

    Then in your HTML you can simply reference the image within the images folder relative to the site, like so:

    <img  src="images/66.jpg" width="400" height="400" />
    

    Or, assuming you're hosting at the root of localhost and not within another virtual directory, you can do this (note the slash in the beginning):

    <img  src="/images/66.jpg" width="400" height="400" />
    
    0 讨论(0)
  • 2020-12-17 04:30

    Another random reason for why your images might not show up is because of something called base href="http://..." this can make it so that the images file doesn't work the way it should. Delete that line and you should be good.

    0 讨论(0)
  • 2020-12-17 04:32

    I had same kind of problem in Netbeans.

    I updated the image location in the project and when I executed the jsp file, the image was not loaded in the page.

    Then I clean and Built the project in Netbeans. Then it worked fine.

    Though you need to check the image actually exists or not using the image URL in the browser.

    0 讨论(0)
提交回复
热议问题