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
BHUSHANGEETEAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
Why do you need the file name in query string? You get already the file name as posted field value.
0
BHUSHANGEETEAuthor Commented:
I am trying to post to the same page. In this case, I am not getting the posted field value.
0
ZvonkoSystems architectCommented:
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>

0
BHUSHANGEETEAuthor Commented:
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.
0
ZvonkoSystems architectCommented:
Check this:
<script>
function checkForm(theForm){
  if(theForm.myText1.value==""){
    alert("Please eneter Text");
    theForm.myText1.focus();
    return false;
  }
  if(theForm.myText2.value==""){
    alert("Please eneter Text");
    theForm.myText2.focus();
    return false;
  }
  return true;
}
</script>
<form name="FORM_A" method="POST" action="submitNominationTeam.jsp" ENCTYPE="multipart/form-data" onSubmit="return checkForm(this)">
  <input type="text" name="myText1">
  <input type="text" name="myText2">
  <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>

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.