2011-04-12 75 views
1

我有一個窗體,我在上傳圖片。我不知道我可以在特定時間上傳多少張照片。有沒有用於在表單中動態添加文件上傳字段的jQuery/AJAX解決方案?jQuery解決方案,用於動態上傳多個文件

+0

在窗體中添加文件場簡單的代碼,你只需要添加窗體文件輸入字段? – 2011-04-12 10:52:33

+0

是的,這是我想要的 – dana 2011-04-12 11:19:49

回答

2

爲使用jQuery

<form id="myForm" action="your-action"> 

    <input type="file" name="files[]" /> 

    <a href="#" onclick="addMoreFiles()">Add More</a> 

</form> 

<script> 
     function addMoreFiles(){ 

      $("#myForm").append('<input type="file" name="files[]" />') 
     } 

</script> 
+0

我會嘗試一下。謝謝 – dana 2011-04-12 11:18:24

+0

它解決了你的問題嗎? – 2011-04-12 13:56:34

+0

不......它不能解決問題。 (上面的小腳本。)沒有添加inut字段。 – dana 2011-04-13 09:59:20