• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 441
  • Last Modified:

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
0
BHUSHANGEETE
Asked:
BHUSHANGEETE
  • 3
  • 2
1 Solution
 
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now