HTML代码:
FAILED: ParseException line 7:11 cannot recognize input near ':' 'array' '<' in column type </b>
jQuery代码:
<input type="file" name="img1" id="img1" required>
<input type="file" name="img2" id="img2">
<input type="file" name="img3" id="img3">
<input type="file" name="img4" id="img4">
我想在用户点击提交按钮时阅读多个文件。但它不起作用。我该如何解决这个错误?请帮我。
答案 0 :(得分:0)
使用Jquery和each()方法我建议:
var checkValue;
var valueArray=[];
$('#button').on('click',function(){
$('input').each(function(){
checkValue=$(this).val();
if(checkValue===''){
return;
}
valueArray.push(checkValue);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" name="img1" id="img1" required>
<input type="file" name="img2" id="img2">
<input type="file" name="img3" id="img3">
<input type="file" name="img4" id="img4">
<button id="button">Click Me</button>
答案 1 :(得分:0)
将click
个事件附加到<input type="submit">
,致电event.preventDefault()
以阻止<form>
提交,使用.each()
来迭代<input type="file">
元素,通过{{ 1}}到this.files[0]
功能。
在readfile
FileReader
处理程序中进行调整,以便不会覆盖load
处的相同密钥。
localStorage
或FileReader
对象未作为参数传递给Blob
,则 File
会引发错误,例如.readAsDataURL()
, if
fileread is clicked and
is called in loop and one of
。文件elements
文件property doe not contain
文件列表object in
。文件. Check if element
。长度为{{1} {0 {1}} FILEREAD has
。files [0] greater than
`element。
before calling