0

I am submitting a simple form to an asp.net page. Everything works fine except the form does not submit the file input values.

<form id="mainform" action="http://<%=Request.Url.Authority %>/ABC/Handler/Submit.aspx" method="post" enctype="multipart/form-data">
<input type='file' id='file_d6'data-mandatory='0' name='file_d6' style='visibility: hidden; position: absolute;'  onchange='showPreview(this)' />
<input type='file' id='file_d7'data-mandatory='0' name='file_d7' style='visibility: hidden; position: absolute;'  onchange='showPreview(this)' />

<input style='height: 100%;' type='submit' class='subCtrl'  onclick='return isReadyToSubmit();' >
</form>

In the function isReadyToSubmit I check the value of all input fields in the form. It shows me values of both file input fiels, but when I submit the form it submits all fields except file input

function isReadyToSubmit()
{
     $("form#mainform :input").each(function(){
         alert($(this).val());
     });
    return true;
}
6
  • 2
    you should specify the input there are 2 types of input. Commented Dec 23, 2015 at 8:10
  • Are you getting other values then type="file"? Commented Dec 23, 2015 at 8:13
  • Why is the input file tag hidden ? Commented Dec 23, 2015 at 8:59
  • @ParthTrivedi: yes there are text inputs and checkboxes i am getting their values in alert box and in aspx page too.. Commented Dec 23, 2015 at 9:09
  • @guradio: can you please explain.. Commented Dec 23, 2015 at 9:10

2 Answers 2

2

The file post is not present in the $_POST but in the $_FILES array. Please try print_r($_FILES); at the top of your PHP script? Hope that this helps

Sign up to request clarification or add additional context in comments.

3 Comments

i am posting this from to an aspx page.
and getting values using Request.Form.GetKey(index)
solved it, I was getting Files using wrong method, using Request.Files[index] solved my issue.
1

The issue was not at client side but was at server side. I was using Request.Form.GetKey(intIndex) it gave me all other input values except files, but using Request.Files[intIndex] solved the issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.