RSS Forums RSS
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1448 | Replies: 2 | Solved
Reply
Join Date: Mar 2006
Posts: 37
Reputation: sree22_happy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
sree22_happy's Avatar
sree22_happy sree22_happy is offline Offline
Light Poster

Question Problem in previewing image after upload in Mozilla

  #1  
Jan 25th, 2008
hi friends

i have a problem in previewing image in mozilla browser.I will give the code.

script code
<script type="text/javascript">
        
      function loading(img)
      {
document.getElementById('disp').src=img;
      }
</script>

jsp page code 
<html:file  property="productImage"  value="${product.productImage}" styleClass="sni_input" onchange="loading(this.value)"/>

 <img src="" id="disp">

only few codes are written.I think you can understand this.
This will work in IE.When i click the browse button and selected a particular image it will be shown below to that browse button.But in Mozilla it wont showing .. please help me
thanks in advance
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 7,053
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 25
Solved Threads: 372
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: Problem in previewing image after upload in Mozilla

  #2  
Jan 25th, 2008
This is because the value which you receive in the upload box is a Windows specific path. IE would obviously know how to interpret it but Mozilla won't.

To make this possible, you have to convert your windows path into a file resource which can be used by all browsers using the file protocol. Try this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Expires" content="0" /> <!-- disable caching -->
    <title>Example</title>
    <script type="text/javascript">
    function getData(srci) {
        srci = srci.replace(/\\/g, "/");    /* convert all \ to / */
        encodeURI(srci);    /* encode the URI to enable escaping */
        srci = "file://" + srci;
        alert("File resource at : " + srci);
        document.images[0].src = srci;  
    }
    </script>
</head>
<body>
    <form action="#">
        <input type="file" onchange="getData(this.value);">
        <br><br>
        <image src="#" alt="image">
    </form>
</body>
</html>
Keep in mind that there is no such thign mentioned in the specification which says that the path to the local resource can be successfully retrieved from the file select control and hence even the above trick might not work in some browsers like Opera.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Join Date: Mar 2006
Posts: 37
Reputation: sree22_happy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
sree22_happy's Avatar
sree22_happy sree22_happy is offline Offline
Light Poster

Re: Problem in previewing image after upload in Mozilla

  #3  
Jan 29th, 2008
its worked thanks
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:11 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC