hai ,
i got an error in javascript, when upload a file in a form,
the code is working properly in IE but i got javascript error in Mozilla firefos
what is mean by error and how to rectify that.
the error is
Error: uncaught exception: [Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location: form1.php
here is the code
================
[HTML]<script language="javascript">
function checkform()
{
varfile = document.form1.file1.value;
if(varfile == "")
{
alert("Select a file to upload");
document.form1.file1.focus();
return false;
}
if(varfile!="")
{
varfile = document.form1.file1.value;
valfoc=document.form1.file1;
valofch=validoffile(varfile,valfoc)
if(valofch==false)
{
valfoc.focus();
return false;
}
}
varfile2= document.form1.file2.value;
if(varfile2!="")
{
varfile2 = document.form1.file2.value;
valfoc2=document.form1.file2;
valofch2=validoffile(varfile2,valfoc2)
if(valofch2==false)
{
valfoc2.focus();
return false;
}
}
}
function validoffile(valofchk,valfoc)
{
var Valu=valofchk;
var Val=Valu.toLowerCase();
var Val1=Val.indexOf('.pdf');
var Val2=Val.indexOf('.zip');
if (Val1==-1 && Val2==-1 )
{
alert('You can attach only any of .pdf, .zipextension file');
return (false);
}
}
function imposeMaxLength(Object, MaxLen)
{
return (Object.value.length < MaxLen);
}
function fnPaste(vEl)
{
var intMaxLength, intCurrLength, strClip ;
var intClipLength, intAvailLength ;
var blnReturn ;
blnReturn = true ;
intMaxLength = vEl.getAttribute("maxlength") ;
intCurrLength = vEl.value.length ;
strClip = window.clipboardData.getData("Text") ;
intClipLength = strClip.length ;
intAvailLength = intMaxLength - intCurrLength ;
if (intAvailLength > 0)
{
if (intAvailLength < intClipLength)
{
strClip = strClip.substr(0, intAvailLength) ;
window.clipboardData.setData("Text",strClip) ;
}
}
else
{
blnReturn = false ;
}
return blnReturn ;
//filesave.php
}
</script>
<form name="form1" action="#" method="post" enctype="multipart/form-data" onsubmit="return checkform()">
<table>
<tr bgcolor="#f6f4f4">
<td><div class="body" align="right">File 1</div></td>
<td><input name="file1" id="file1" class="textfieldbig" type="file" unselectable="on">
*</td>
</tr>
<tr bgcolor="#f6f4f4">
<td><div class="body" align="right">Description For File 1</div></td>
<td><textarea class="messagebox" id="textarea1" name="desfile1" onkeypress="return imposeMaxLength(this, 1500);" onpaste="return fnPaste(this);" maxlength=1500 ></textarea></td>
</tr>
<tr bgcolor="#f6f4f4">
<td><div class="body" align="right">File 2</div></td>
<td><input name="file2" class="textfieldbig" type="file" unselectable="on"></td>
</tr>
<tr bgcolor="#f6f4f4">
<td><div class="body" align="right">Description For File 2</div></td>
<td><textarea class="messagebox" id="textarea1" name="desfile2" onkeypress="return imposeMaxLength(this, 1500);" onpaste="return fnPaste(this);" maxlength=1500 ></textarea></td>
</tr>
</table>[/HTML]