How to retrieve and show images from another drive using src attribute in tag?











up vote
-1
down vote

favorite












<img src="d:/Tulips.jpg" >
</img>

<img src="file:///d:Tulips.jpg">


How to retrieve and show images from another drive using src attribute in <img> tag?
If the image is in the same folder it works but when the source of the image is on another drive it's not working.










share|improve this question




















  • 2




    Show us what you've tried and give examples of it working and not working.
    – Jeff
    Apr 4 '14 at 6:44










  • <img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
    – shwe45
    Apr 4 '14 at 6:49















up vote
-1
down vote

favorite












<img src="d:/Tulips.jpg" >
</img>

<img src="file:///d:Tulips.jpg">


How to retrieve and show images from another drive using src attribute in <img> tag?
If the image is in the same folder it works but when the source of the image is on another drive it's not working.










share|improve this question




















  • 2




    Show us what you've tried and give examples of it working and not working.
    – Jeff
    Apr 4 '14 at 6:44










  • <img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
    – shwe45
    Apr 4 '14 at 6:49













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











<img src="d:/Tulips.jpg" >
</img>

<img src="file:///d:Tulips.jpg">


How to retrieve and show images from another drive using src attribute in <img> tag?
If the image is in the same folder it works but when the source of the image is on another drive it's not working.










share|improve this question















<img src="d:/Tulips.jpg" >
</img>

<img src="file:///d:Tulips.jpg">


How to retrieve and show images from another drive using src attribute in <img> tag?
If the image is in the same folder it works but when the source of the image is on another drive it's not working.







php html image






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 4 '14 at 8:29









Shankar Damodaran

59.7k1267109




59.7k1267109










asked Apr 4 '14 at 6:44









shwe45

812




812








  • 2




    Show us what you've tried and give examples of it working and not working.
    – Jeff
    Apr 4 '14 at 6:44










  • <img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
    – shwe45
    Apr 4 '14 at 6:49














  • 2




    Show us what you've tried and give examples of it working and not working.
    – Jeff
    Apr 4 '14 at 6:44










  • <img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
    – shwe45
    Apr 4 '14 at 6:49








2




2




Show us what you've tried and give examples of it working and not working.
– Jeff
Apr 4 '14 at 6:44




Show us what you've tried and give examples of it working and not working.
– Jeff
Apr 4 '14 at 6:44












<img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
– shwe45
Apr 4 '14 at 6:49




<img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
– shwe45
Apr 4 '14 at 6:49












3 Answers
3






active

oldest

votes

















up vote
2
down vote



accepted










jpgYou can't put your file system path in the src unless you open it from your desktop or your computer. You can try to pass the file as base64 encoded strings. I'm showing how to do it in PHP because you tagged this question with PHP



$image = file_get_contents('d:/Tulips.jpg');

$image_codes = base64_encode($image);


And in your html put it like this.



<image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />





share|improve this answer























  • Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
    – shwe45
    Apr 4 '14 at 7:07












  • @shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
    – Shankar Damodaran
    Apr 4 '14 at 7:17












  • i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
    – shwe45
    Apr 4 '14 at 7:21










  • Nah, why don't you create an image upload folder where you are running the script from ? If you are worried about the security of your images , then you can use .htaccess to restrict direct access to your image folder.
    – Shankar Damodaran
    Apr 4 '14 at 7:24








  • 1




    I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to use RAID but expensive. Or you can upload to both your webroot as the primary storage and d: as backup. I've edited my answer. Should work now.
    – iamsleepy
    Apr 4 '14 at 7:33




















up vote
1
down vote













Try



<img src="file:///d:/Tulips.jpg">


You were missing a slash after your drive lettter.






share|improve this answer

















  • 2




    still its not working
    – shwe45
    Apr 4 '14 at 6:52


















up vote
0
down vote













The reason is you are doing the inevitable.



HTML markups cannot read data from the local disk drives, you need to put them in a folder or access it from the same directory for this to work.



Since, when you publish your website images are to be accessed from the folders of your webserver, accessing from a hard-drive directly (not possible via HTML though) puts you under potential risks.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22855443%2fhow-to-retrieve-and-show-images-from-another-drive-using-src-attribute-in-img%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    jpgYou can't put your file system path in the src unless you open it from your desktop or your computer. You can try to pass the file as base64 encoded strings. I'm showing how to do it in PHP because you tagged this question with PHP



    $image = file_get_contents('d:/Tulips.jpg');

    $image_codes = base64_encode($image);


    And in your html put it like this.



    <image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />





    share|improve this answer























    • Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
      – shwe45
      Apr 4 '14 at 7:07












    • @shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
      – Shankar Damodaran
      Apr 4 '14 at 7:17












    • i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
      – shwe45
      Apr 4 '14 at 7:21










    • Nah, why don't you create an image upload folder where you are running the script from ? If you are worried about the security of your images , then you can use .htaccess to restrict direct access to your image folder.
      – Shankar Damodaran
      Apr 4 '14 at 7:24








    • 1




      I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to use RAID but expensive. Or you can upload to both your webroot as the primary storage and d: as backup. I've edited my answer. Should work now.
      – iamsleepy
      Apr 4 '14 at 7:33

















    up vote
    2
    down vote



    accepted










    jpgYou can't put your file system path in the src unless you open it from your desktop or your computer. You can try to pass the file as base64 encoded strings. I'm showing how to do it in PHP because you tagged this question with PHP



    $image = file_get_contents('d:/Tulips.jpg');

    $image_codes = base64_encode($image);


    And in your html put it like this.



    <image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />





    share|improve this answer























    • Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
      – shwe45
      Apr 4 '14 at 7:07












    • @shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
      – Shankar Damodaran
      Apr 4 '14 at 7:17












    • i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
      – shwe45
      Apr 4 '14 at 7:21










    • Nah, why don't you create an image upload folder where you are running the script from ? If you are worried about the security of your images , then you can use .htaccess to restrict direct access to your image folder.
      – Shankar Damodaran
      Apr 4 '14 at 7:24








    • 1




      I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to use RAID but expensive. Or you can upload to both your webroot as the primary storage and d: as backup. I've edited my answer. Should work now.
      – iamsleepy
      Apr 4 '14 at 7:33















    up vote
    2
    down vote



    accepted







    up vote
    2
    down vote



    accepted






    jpgYou can't put your file system path in the src unless you open it from your desktop or your computer. You can try to pass the file as base64 encoded strings. I'm showing how to do it in PHP because you tagged this question with PHP



    $image = file_get_contents('d:/Tulips.jpg');

    $image_codes = base64_encode($image);


    And in your html put it like this.



    <image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />





    share|improve this answer














    jpgYou can't put your file system path in the src unless you open it from your desktop or your computer. You can try to pass the file as base64 encoded strings. I'm showing how to do it in PHP because you tagged this question with PHP



    $image = file_get_contents('d:/Tulips.jpg');

    $image_codes = base64_encode($image);


    And in your html put it like this.



    <image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 4 '14 at 7:30

























    answered Apr 4 '14 at 7:00









    iamsleepy

    51037




    51037












    • Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
      – shwe45
      Apr 4 '14 at 7:07












    • @shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
      – Shankar Damodaran
      Apr 4 '14 at 7:17












    • i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
      – shwe45
      Apr 4 '14 at 7:21










    • Nah, why don't you create an image upload folder where you are running the script from ? If you are worried about the security of your images , then you can use .htaccess to restrict direct access to your image folder.
      – Shankar Damodaran
      Apr 4 '14 at 7:24








    • 1




      I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to use RAID but expensive. Or you can upload to both your webroot as the primary storage and d: as backup. I've edited my answer. Should work now.
      – iamsleepy
      Apr 4 '14 at 7:33




















    • Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
      – shwe45
      Apr 4 '14 at 7:07












    • @shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
      – Shankar Damodaran
      Apr 4 '14 at 7:17












    • i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
      – shwe45
      Apr 4 '14 at 7:21










    • Nah, why don't you create an image upload folder where you are running the script from ? If you are worried about the security of your images , then you can use .htaccess to restrict direct access to your image folder.
      – Shankar Damodaran
      Apr 4 '14 at 7:24








    • 1




      I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to use RAID but expensive. Or you can upload to both your webroot as the primary storage and d: as backup. I've edited my answer. Should work now.
      – iamsleepy
      Apr 4 '14 at 7:33


















    Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
    – shwe45
    Apr 4 '14 at 7:07






    Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
    – shwe45
    Apr 4 '14 at 7:07














    @shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
    – Shankar Damodaran
    Apr 4 '14 at 7:17






    @shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
    – Shankar Damodaran
    Apr 4 '14 at 7:17














    i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
    – shwe45
    Apr 4 '14 at 7:21




    i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
    – shwe45
    Apr 4 '14 at 7:21












    Nah, why don't you create an image upload folder where you are running the script from ? If you are worried about the security of your images , then you can use .htaccess to restrict direct access to your image folder.
    – Shankar Damodaran
    Apr 4 '14 at 7:24






    Nah, why don't you create an image upload folder where you are running the script from ? If you are worried about the security of your images , then you can use .htaccess to restrict direct access to your image folder.
    – Shankar Damodaran
    Apr 4 '14 at 7:24






    1




    1




    I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to use RAID but expensive. Or you can upload to both your webroot as the primary storage and d: as backup. I've edited my answer. Should work now.
    – iamsleepy
    Apr 4 '14 at 7:33






    I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to use RAID but expensive. Or you can upload to both your webroot as the primary storage and d: as backup. I've edited my answer. Should work now.
    – iamsleepy
    Apr 4 '14 at 7:33














    up vote
    1
    down vote













    Try



    <img src="file:///d:/Tulips.jpg">


    You were missing a slash after your drive lettter.






    share|improve this answer

















    • 2




      still its not working
      – shwe45
      Apr 4 '14 at 6:52















    up vote
    1
    down vote













    Try



    <img src="file:///d:/Tulips.jpg">


    You were missing a slash after your drive lettter.






    share|improve this answer

















    • 2




      still its not working
      – shwe45
      Apr 4 '14 at 6:52













    up vote
    1
    down vote










    up vote
    1
    down vote









    Try



    <img src="file:///d:/Tulips.jpg">


    You were missing a slash after your drive lettter.






    share|improve this answer












    Try



    <img src="file:///d:/Tulips.jpg">


    You were missing a slash after your drive lettter.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 4 '14 at 6:50









    stealthyninja

    9,475103947




    9,475103947








    • 2




      still its not working
      – shwe45
      Apr 4 '14 at 6:52














    • 2




      still its not working
      – shwe45
      Apr 4 '14 at 6:52








    2




    2




    still its not working
    – shwe45
    Apr 4 '14 at 6:52




    still its not working
    – shwe45
    Apr 4 '14 at 6:52










    up vote
    0
    down vote













    The reason is you are doing the inevitable.



    HTML markups cannot read data from the local disk drives, you need to put them in a folder or access it from the same directory for this to work.



    Since, when you publish your website images are to be accessed from the folders of your webserver, accessing from a hard-drive directly (not possible via HTML though) puts you under potential risks.






    share|improve this answer



























      up vote
      0
      down vote













      The reason is you are doing the inevitable.



      HTML markups cannot read data from the local disk drives, you need to put them in a folder or access it from the same directory for this to work.



      Since, when you publish your website images are to be accessed from the folders of your webserver, accessing from a hard-drive directly (not possible via HTML though) puts you under potential risks.






      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        The reason is you are doing the inevitable.



        HTML markups cannot read data from the local disk drives, you need to put them in a folder or access it from the same directory for this to work.



        Since, when you publish your website images are to be accessed from the folders of your webserver, accessing from a hard-drive directly (not possible via HTML though) puts you under potential risks.






        share|improve this answer














        The reason is you are doing the inevitable.



        HTML markups cannot read data from the local disk drives, you need to put them in a folder or access it from the same directory for this to work.



        Since, when you publish your website images are to be accessed from the folders of your webserver, accessing from a hard-drive directly (not possible via HTML though) puts you under potential risks.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 4 '14 at 7:18

























        answered Apr 4 '14 at 7:06









        Shankar Damodaran

        59.7k1267109




        59.7k1267109






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22855443%2fhow-to-retrieve-and-show-images-from-another-drive-using-src-attribute-in-img%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()