You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ion Iulian <i....@finsiel.ro> on 2004/09/06 17:35:23 UTC
Javascript: Access is denied when I try to upload a file
Hi. I want to upload a file and I use another button to select the file. I press the button "Sfoglia", and after the file is selected when I press "Acquisizione" to make submit the following javascript error occur "Access is denied". What's wrong?? Please help me.
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<head>
<title>Uploading form</title>
<html:base/>
</head>
<BODY>
<script language="JavaScript">
function azione11(azione)
{
document.forms[0].action=azione;
document.forms[0].submit();
}
function showText(txtId)
{
if (txtId == "" ){
document.getElementById('layer1').style.display='none';
document.getElementById('layer2').style.display='none';
document.getElementById('textid').style.display='none';
document.getElementById('textid').innerHTML="";
}
else{
document.getElementById('layer1').style.display='block';
document.getElementById('layer2').style.display='block';
document.getElementById('textid').style.display='block';
document.getElementById('textid').innerHTML="Foglio excel - "+txtId;
}
}
</script>
<html:form action="ricercaEsportazioni.do" enctype="multipart/form-data">
<hr width="70%">
<div id="layer1" style="display:none" align="center">
<table width="70%" border="0" cellPadding="3" cellSpacing="1">
<tr>
<td width="15%" align="center" nowrap>
</div>
<font class="output"><div id=textid style="display:none"></div></font>
<div id="layer2" style="display:none" align="center">
</td>
</tr>
</table>
</div>
<hr width="70%">
<table width="70%" border="0" cellPadding="3" cellSpacing="1" align="center">
<tr>
<td align="center">
<html:button property="acquisizione" onclick="javascript:document.forms[0].submit()" >
Acquisizione
</html:button>
<html:button property="sfoglia" onclick="fileUpload.click()" >
Sfoglia
</html:button>
<html:file property="fileUpload" onchange="javascript:showText(document.forms[0].fileUpload.value)" style="display:none"/>
</td>
</tr>
</table>
</html:form>
<html:errors/>
</html:html>
P.S. I must use style diplay:none at the html:file tag.