<script language="javascript">
//BEGIN FROM http://weblogs.macromedia.com/cantrell/archives/2004/06/how_to_implemen.cfm
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;
//END FROM http://weblogs.macromedia.com/cantrell/archives/2004/06/how_to_implemen.cfm
{
var img = new Image();
img.src = 'file://'+path;
document.write(img.width + ' pixels wide x ' + img.height +' pixels high<br>'+ '<img src=' + img.src + '><br>');
}
{
// BEGIN FROM: http://www.quirksmode.org/js/filesize.html
var size = (document.fileSize)*1;
var y = document.images;
var imglength = 0;
for (i=0;i<y.length;i++)
{
imglength += (y[i].fileSize)*1;
}
var total = size + imglength;
//uncomment the following to return more page info
//var writestring = 'File size HTML: ' + size;
//writestring += '\nFile size images: ' + imglength;
//writestring += '\nTotal file size: ' + total;
// END FROM: http://www.quirksmode.org/js/filesize.html
var writestring = 'Image file size: ' + imglength + ' bytes<br>' ;
if (imglength < 1) writestring += "<b>NOT APPLICABLE: \nFile too large for this script.</B><BR>";
//if (total > 40000) writestring += "\nFile too large!" + '<a href="javascript: history.go(-1)"><br>RETURN TO PREVIOUS PAGE</a>';
if (imglength > 40000) writestring += "\nFile too large!" + '<a href="javascript: history.go(-1)"><br>RETURN TO PREVIOUS PAGE</a>';
//if (total < 40000) writestring += "\nFile size OK." + '<a href="javascript: history.go(-1)"><br>RETURN TO PREVIOUS PAGE</a>';
//if (imglength >= 1)writestring += "\nFile size OK." + '<a href="javascript: history.go(-1)"><br>RETURN TO PREVIOUS PAGE</a>';
if (((40000 + imglength)<40000)) writestring +="\nFile size not OK." + '<a href="javascript: history.go(-1)"><br>RETURN TO PREVIOUS PAGE</a>' ;
if (((40000 + imglength)>40000)) writestring +="\nFile size OK." + '<a href="javascript: history.go(-1)"><br>RETURN TO PREVIOUS PAGE</a>' ;
document.write(writestring);
}
}
else
{
alert("JPG, PNG, and GIFs only!");
}
}
</script>