Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

preview of an image for uploading in firefox

 
Chandra S Marappa
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the script i have used to show the preview of an image that is selected for uploading. This script is working well in IE but not in firefox. can u help me out of this... so that we can show preview in firefox also.

--------------------------------------------------------
<script language="javascript">
var imgRe = /^.+\.(jpg|jpeg|gif|png)$/i;
function previewImage(pathField, previewName)
{
var path = pathField.value;
if (path.search(imgRe) != -1)
{
document[previewName].src = 'file://'+path;
}
else
{
alert("JPG, PNG, and GIFs only!");
}
}
</script>

<div align="center">
<form name="imageTest">
<input type="file"
name="myImage"
size="30"/>
<input type="button"
value="Preview!"
on Click="previewImage(document.imageTest.myImage,
'replaceMe')"/><br>
<img src="images/clear.gif" name="replaceMe"/>
</form>
</div>
------------------------------------------------------------------------
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Eric
 
Chandra S Marappa
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the same code is saved as a file with *.jsp and deployed in Weblogic server, and then try to upload a image in firefox, firefox is not showing the preview, but in IE it is working fine. could u suggest me how to make the same code work both in IE & firefox.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic