Link to home
Start Free TrialLog in
Avatar of BHUSHANGEETE
BHUSHANGEETE

asked on

file Upload issue with Special characters

Hi, I am trying to upload the files in JSP. I am getting errros when the file name/folder name has special characters like &,'. Could you please help me out how to do the urlencode and decode the same.

Here is snippet of my code.
<form name="FORM_A" method="POST" ENCTYPE="multipart/form-data">
  <input name="fileName" size="50" type="file">&nbsp;&nbsp;<a onClick="javascript:validation(this)"><img src="../images/buttons/btn_attach.gif" name="attach" width="61" height="15" border="0" alt="Attach"></a>
</form>
<script language ="javascript">
function validation(f) {      
document.FORM_A.action = "submitNominationTeam.jsp?fileName=" + escape(document.FORM_A.fileName.value)document.FORM_A.submit();
return;  
}

Any help would be appreciated.

Thanks
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Why do you need the file name in query string? You get already the file name as posted field value.
Avatar of BHUSHANGEETE
BHUSHANGEETE

ASKER

I am trying to post to the same page. In this case, I am not getting the posted field value.
Check this:

<form name="FORM_A" method="POST" action="submitNominationTeam.jsp" ENCTYPE="multipart/form-data">
  <input name="fileName" size="50" type="file">&nbsp;&nbsp;
  <input type="submit" name="attach" value="" style="background:url('../images/buttons/btn_attach.gif'); width:61; height:15; border:0;" alt="Attach">
</form>

Hi, I do have couple of text box controls in the same form which are mandatory fields, I need to validate 'em  before submitting the form.
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial