IE 7 FileUpload display image using Javascript

Last post 01-29-2007 12:03 PM by lizgee. 4 replies.

Sort Posts:

  • IE 7 FileUpload display image using Javascript

    01-25-2007, 1:41 AM
    • Loading...
    • lizgee
    • Joined on 01-25-2007, 1:14 AM
    • Posts 8

    I just joined this site, and am working on similar issues.  I have already incorporated all the suggestions in this thread, and in addition, am displaying an image prior to uploading using javascript.  This seems to work fine in IE 6, but not IE 7.

    <script language="javascript"  type="text/javascript">
    function showBrowse(pFile, idx)
    {
    imgThumb = eval("document.images.img" + idx);
    imgThumb.src = pFile;
    }
    </script>
    ...

    <asp:FileUpload ID="PhotoFile0" runat="server" onchange="showBrowse(this.value,0);" />

     <img id="img0" alt="imgQ0" height="48" width="64" src="../Images/bg/spacer.gif" runat="server"/>

  • Re: IE 7 FileUpload display image using Javascript

    01-25-2007, 8:13 AM
    • Loading...
    • A1ien51
    • Joined on 05-06-2005, 6:46 PM
    • MD USA
    • Posts 2,852

    There are 1000000s of threads here, would be nice to know what one you were talking about.

     FYI: eval is the wrong way of doing that

    document.images["img" + idx] or document.getElementById("img" + idx) would be the correct way.

     Eric

    Coauthor of Ajax In Action [#1 Computer and Internet book on Amazon for 2006]

    If you get an answer to your question, please mark it solved so people don't waste time reading already answered questions!
  • Re: IE 7 FileUpload display image using Javascript

    01-25-2007, 4:19 PM
    • Loading...
    • lizgee
    • Joined on 01-25-2007, 1:14 AM
    • Posts 8

    Cannot get it to work localhost remote  webserver, on IE7, Netscape or Firefox, but I can get the same page to work if I place it on my local drive in an html page.

    (These work fine in IE6 on .aspx or html page from my published web app)

    I can get it to work by pasting the same code in an HTML page in Netscape and Firefox and IE6 from my local host or remote server, not running in a web app.

    Is there an IE7 add-in, or a .Net 2.0 configuration setting that will allow this to work?

        <script type="text/javascript" language="javascript">
        function showBrowse(pFile, idx)
    {
      var reslash = "file://" + pFile;
        imgThumb = document.images["img" + idx];
        imgThumb.src = reslash;
        var brow = navigator.appName;
        var browver = navigator.appVersion; //.substr(0,1);
        var brocn = navigator.appCodeName;
        var broua = navigator.userAgent;
        alert(pFile + "\n\r browser: " + brow + "\n\r version= " + browver + "\n\r codename=" + brocn + "\n\r useragent=" + broua);
         caption = eval('document.getElementById("Text' + idx + '")');
        caption.style.display   = "block";
        caption.value     = reslash;
    }
        </script>
    </head>
    <body>
    <form id="form1" runat="server">
        <div>
        <table >
        <tr>
            <td><input name="fileSimple1" type="file" size="32"  onchange="showBrowse(this.value, 0);"  class="textfield"/></td>
        </tr>
        <tr>
            <td><img id="img0" alt="imgQ0" height="48" width="64" src="../Images/bg/spacer.gif" /><br />
                <input id="Text0" type="text" runat="server" class="fileUpload" style="width: 338px" />   
            </td>
        </tr>
        <tr>
        <td > <input id="btnPutImageSrc" type="button" value="put text in image src"
                        onclick="document.images.img1.src = document.getElementById('Text0').value;"/></td>
        </tr>
        <tr>
            <td><img id="img1" alt="imgQ1" height="48" width="64" src="../Images/bg/spacer.gif" runat="server"/></td>
        </tr>

        <tr>
                <td><input name="fileSimple" type="file" size="32" onchange="document.images.preview.src =(this.value)" /> </td>
        </tr>
        <tr>
        <td><img name="preview" id="preview" src="images/bg/spacer.gif" width="75" height="90" alt="Members Photo"/>preview</td>
       
        </tr></table>
        </div>
        </form>
    </body>

  • Re: IE 7 FileUpload display image using Javascript

    01-25-2007, 4:24 PM
    • Loading...
    • A1ien51
    • Joined on 05-06-2005, 6:46 PM
    • MD USA
    • Posts 2,852

    IE 7 changed security settings and local drive verus localhost are two different security zones.

    Eric

    Coauthor of Ajax In Action [#1 Computer and Internet book on Amazon for 2006]

    If you get an answer to your question, please mark it solved so people don't waste time reading already answered questions!
  • Re: IE 7 FileUpload display image using Javascript

    01-29-2007, 12:03 PM
    • Loading...
    • lizgee
    • Joined on 01-25-2007, 1:14 AM
    • Posts 8

    Please advise which settings this might be.  I looked under:

    Internet Options>Tools>Security>

    Include local directory path when uploading files to a server - Enabled

    I could not find an option for local drive ... which category is this under?

    Liz 

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter