1
我通過網絡搜索,但沒有發現我的問題很多事情。希望這裏有人能幫助! 正如我在標題中寫的,我想上傳多個文件,一次只能輸入一個。 我試圖使用JQuery來做到這一點,如下所示,但顯然它不起作用! 任何人都可以幫忙嗎?JQuery/PHP多個文件一次只有一個輸入字段
<!doctype html>
<html>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<head>
<script>
$(document).ready(function() {
$(document).on('change', '.file',function(){
$('<input type="file" name="file[]" class="file" size="60" />').appendTo($("#divAjout"));
$("div input:first-child").remove();
return false;
});
});
</script>
<title>test input file unique pour plusieurs fichiers</title>
</head>
<body>
<form action="" method="post" enctype='multipart/form-data'>
<div id="divAjout">
<input type="file" name="file[]" class="file" id='file' size="60" />
</div>
<input name="submit" type="submit">
</form>
<?php if(isset($_POST['submit'])){echo'<pre>'; print_r($_FILES);echo'<pre>';} ?>
</body>
</html>
首先在谷歌搜索給了我:http://davidwalsh.name/multiple-file-upload –
爲什麼你刪除第一個輸入,當你添加一個新的?該文件尚未上傳。 – Barmar
繼承人另一個與JQuery完成http://blueimp.github.io/jQuery-File-Upload/ – cmorrissey