Changing image of Image control on Client-side

Discussion in 'JavaScript' started by r_honey, Jun 7, 2008.

  1. #1
    One of my forms allows authorized users to upload images.

    Initially I wanted a normal Button along-side an Image control, which when clicked opens a File-Choose Dialog. The user selected file is stright-away displayed in the ImageBox (without any Postbacks or Callbacks). The file would be uploaded to the server when the user clicks another button (called "Update"), which post-backs the entire form to the server. Is this possible???

    I don't think so, because later I realized that there needs to be a FileUpload control to send a File from client to the server.

    So, I changed my strategy. Now, I have put a FileUpload control, along-side the ImageBox. The rest of the scenario remains the same. User chooses a File, which is displayed in the ImageBox straight-away, and is sent back only on clicking the "Update" button.

    I am using the following code to change the image on he client-side with a client-side path:

    
    //JavaScript funciton 
    
    <script language="javascript" type="text/javascript">   
            function LoadImage(){
    
                  document.getElementById('img').src=document.getElementById('File1').value;      
            }   
            </script>
    
     ////Form Code
    
    <form id="form1" runat="server">
            <input id="File1" type="file" onchange="show()" />       
            <img id="img" src="" alt="Image" />
        </form> 
    
    Code (markup):
    Although the onchange event fired after a File was selected, but the Image did not change in the image control. Can somebody help me in figuring out, how to change the image of an Image Box on the client side, with a client-side image path???
     
    r_honey, Jun 7, 2008 IP
  2. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #2
    crath, Jun 8, 2008 IP
  3. r_honey

    r_honey Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Looks like there is no reliable, cross-platform technology to achieve this task right now:(
     
    r_honey, Jun 8, 2008 IP