Retrieve image files from local system

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • veenna
    New Member
    • Dec 2007
    • 65

    Retrieve image files from local system

    How can i retrieve image files from a local system's My pictures folder and display those images?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    JavaScript doesn't allow access to the local file system, so this isn't really possible by just setting the src of images to the local filepath.

    What you can do is use an input file element and upload the file to the server and then display it.

    Comment

    • KalariaNitya
      New Member
      • Apr 2008
      • 34

      #3
      for that, u have to make one function on server side which manage current folder path

      and called that function from inline on that img button..

      [CODE=asp]<A href='<%#Format URL1(DataBinder .Eval(Container .DataItem,"prod _id"))%>' onclick="window .open(this.href ,'','scrollbars =no, menubar=no, toolbar=no, resizable=yes, status=no, width=800, height=600'); return false;" target="_blank" ><asp:Image id="Image1" runat="server" CssClass="borde r_img" ImageUrl='<%# FormatURL(DataB inder.Eval(Cont ainer.DataItem, "prod_id")) %>' BorderStyle="So lid" BorderWidth="1p x">
      [/CODE]

      where FormatURL1 is server side function
      Last edited by gits; May 10 '08, 11:56 AM. Reason: added code tags

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        as acoder said already: javascript doesn't allow access to the local filesystem of the client ... and it should NOT! ... imagine a webpage that could access your filesystem ... nobody wants that. of course you could use some privileges or security settings in an environment where you could control such things (local machine or an intranet) ... but on a public site you cannot control the users settings ...

        kind regards

        Comment

        • veenna
          New Member
          • Dec 2007
          • 65

          #5
          Please check this link


          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Yes, but have you read the page properly? It requires ActiveX, works in IE only, the security must be lowered, a security warning pops up, etc.

            Comment

            • veenna
              New Member
              • Dec 2007
              • 65

              #7
              Originally posted by acoder
              Yes, but have you read the page properly? It requires ActiveX, works in IE only, the security must be lowered, a security warning pops up, etc.

              yes, i know that.

              But using the same way is it possible to retrieve image files from the local system?

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5388

                #8
                is that a question? the answers are up there already. if you have an IE - and an IE not on a MAC - so: if you have an IE and windows and lower the security settings and use ActiveX - you may retrieve files from the local file system ... so the answer is yes. but as you see ... this is really useless for a public webpage ... but it could make sense for a intranet-environment where you have control over all that things that are preliminaries for that 'solution' ...

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  One thing that can be added is that IE6 will allow you to set the source of an image to a local file by default. IE7 wouldn't by default and neither would other browsers.

                  Comment

                  • rnd me
                    Recognized Expert Contributor
                    • Jun 2007
                    • 427

                    #10
                    Originally posted by acoder
                    One thing that can be added is that IE6 will allow you to set the source of an image to a local file by default. IE7 wouldn't by default and neither would other browsers.

                    seems to work in firefox:
                    Code:
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <html xmlns="http://www.w3.org/1999/xhtml">
                    <head><title>local image test</title>
                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                    <style type='text/css'></style></head><body >
                    
                    image url:<input type='text'  id='url' value=''  />	&nbsp;<input type='button'  id='' value='load it' onclick="loadit()" />	<br />
                    
                    <br /><hr />
                    
                    <img src="hello.jpg"  id="img" alt="" border="0"    />	
                    
                    <hr />
                    
                    <script type='text/javascript'>
                    
                    function el(tid) {return document.getElementById(tid);}
                    	function loadit(){
                    		el("img").src=el("url").value;	
                    }
                    
                    
                    </script></body></html>

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      Either you're testing locally, or you've changed the default settings. It doesn't work for me. You may have security.checkl oaduri set to false if it's working non-locally.

                      Comment

                      Working...