在javascript中,(document.getElementById(“ file”)。files [0] .name)不能提供本地服务器的文件名
错误:未捕获的TypeError:无法读取未定义的属性“名称”
HTML
<?php $j=10; for($i=0; $i<=$j;$i++){?><div>
<a href="#" title="Give some input related to this track" data-toggle="modal" data-target=".bs-example-modal-lgdata<?php echo $i;?>"><i class="fa fa-pencil-square-o"></i></a>
<div class="modal fade bs-example-modal-lgdata<?php echo $i;?>" tabindex="-1" role="dialog" aria-hidden="true">
<form data-parsley-validate class="form-horizontal form-label-left" action="../text.php" method="post">
<input type="file" name="file" id="file" multiple="multiple" required >
</p>
<span id="uploaded_image"></span>
<div>
</div>
</div>
</div>
<?php }?>
javascript
<script>
$(document).ready(function(){
$(document).on('change', '#file', function(){
$('div.loader').show();
var name = document.getElementById("file").files[0].name;
});
});
</script>