使用Angular.js选择文件时遇到问题。这是我的代码:
<div ng-class="{'myError': billdata.compregdoc.$touched && billdata.compregdoc.$invalid }">
<input type="file"
class="filestyle form-control"
data-size="lg"
name="compregdoc"
id="compregdoc"
ng-model="compregfile"
ngf-pattern="application/pdf,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.wordprocessingml.document"
accept="application/pdf,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.wordprocessingml.document"
ngf-select="onCompRegFileSelect($file);"
ngf-max-size="2MB">
<div style="clear:both;"></div>
</div>
</div>
<div class="help-block"
ng-messages="billdata.compregdoc.$error"
ng-if="billdata.compregdoc.$touched">
<p ng-message="pattern" style="color:#F00;">This field only accepts .pdf,.ppt,.docx files.</p>
<p ng-message="maxSize" style="color:#F00;">File is too large.Max size is 2 mb.</p>
</div>
在这种情况下,我只能上传pdf
类型文件。但在这里我需要pdf,ppt,docx,excel
格式文件上传。当我选择docx文件时,它会向我显示This field only accepts .pdf,.ppt,.docx files
。