问题是由于您有 2 个具有相同上传 ID 的控件。你的包装div
和你的submit
按钮。
要修复它,只需从提交按钮中删除id
和属性。name
你也有无效的br
标签。我也修复了这些。
请参阅工作 jsFiddle 演示
我会让你清理标记和 css 以使框和它的控件对齐并且看起来很漂亮。=D
HTML
<div id="upload">
<form action='http://test' method='post' accept-charset='utf-8' class='form-horizontal' enctype='multipart/form-data' style='text-align:center;'>
<br />
<div class='control-group'>
<input type='file' name='userfile' value='' id='userfile' class='btn btn-primary' required='true' style=' width:290px;' />
<br />
<br />
<label for='name'>Name</label>
<input type='text' name='associateName' value='' id='name' required='required' placeholder='Name' />
</div>
<div class='control-group'>
<label for='dept'>Department Name</label>
<input type='text' name='dept' value='' id='dept' required='required' placeholder='Department Name' />
<br />
<input id='startDateUpload' name='startDateUpload' value='" + $.datepicker.formatDate(dateFormat, startDate, inst.settings) + "' type='hidden' />
<input id='endDateUpload' name='endDateUpload' value='" + $.datepicker.formatDate(dateFormat, endDate, inst.settings) + "' type='hidden' />
<input id='seg' name='seg' value='0' type='hidden' />
<input id='total' name='total' type='hidden' />
</div>
<input type='submit' value='Upload' class='con btn btn-primary' />
</form>
</div>
CSS
#upload
{
width: 40%;
height: 40%;
margin-right: auto;
margin-left: auto;
background: -webkit-gradient(linear, left top, left bottom, color-stop(5%, #fff), color-stop(90%, #f2f2f2));
box-shadow: 10px 10px 5px #888888;
border: 2px solid #d6d6d6;
}