简体   繁体   English

表单未提交输入类型=“文件”值

[英]Forms not submitting Input type=“file” values

I am submitting a simple form to an asp.net page. 我正在向asp.net页面提交一个简单的表单。 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. 在函数isReadyToSubmit中,我检查表单中所有输入字段的值。 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;
}

The file post is not present in the $_POST but in the $_FILES array. 该文件发布不在$ _POST中,而是在$ _FILES数组中。 Please try print_r($_FILES); 请尝试print_r($ _ FILES); at the top of your PHP script? 在您的PHP脚本顶部? Hope that this helps 希望这会有所帮助

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. 我当时使用Request.Form.GetKey(intIndex ),它给了我除文件以外的所有其他输入值,但是使用Request.Files[intIndex]解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM