File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes preview of an image for uploading in firefox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "preview of an image for uploading in firefox" Watch "preview of an image for uploading in firefox" New topic
Author

preview of an image for uploading in firefox

Chandra S Marappa
Greenhorn

Joined: Apr 26, 2005
Posts: 19
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>
------------------------------------------------------------------------


Regds<br />---------------<br />Chandru
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6


Eric
Chandra S Marappa
Greenhorn

Joined: Apr 26, 2005
Posts: 19
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: preview of an image for uploading in firefox