2016-08-20 78 views
0

這裏是我的代碼: -如何在jQuery中重複文件上傳輸入框?

這是我的腳本代碼和HTML代碼。

$(document).ready(function() { 
    $('input[type="file"]').ajaxfileupload({ 
     'action' : 'UploadFile', 
     'onComplete' : function(response) { 
     $('#upload').hide(); 
     $('#message').show(); 

     var statusVal = JSON.stringify(response.status); 

     if(statusVal == "false") 
    { 
    $("#message").html("<font color='red'>"+JSON.stringify(response.message)+"</font>"); 
} 
    if(statusVal == "true") 
    { 
    $("#message").html("<font color='green'>"+JSON.stringify(response.message)+"</font>"); 
    }     
}, 
    'onStart' : function() { 
     $('#upload').show(); 
     $('#message').hide(); 
    } 
    }); 
    }); 

這是在我已經給出選擇上傳文件的正文部分。

<form> 
<div class="centered"> 


    <input type="file" name="file" /><br /> 
    <div id="upload" style="display: none;">Uploading..</div> 
    <div id="message"></div> 
    </div> 
    </form> 

我想添加一個選項,使用jquery或ajax在同一頁面上載更多文件?

+0

我想給動態選項添加更多的上傳文件選項。 –

回答

0

文件輸入可以採用多個選項,如W3S所述。但請注意,它在舊版瀏覽器中並不普遍支持。如果你正在尋找更多的jQuery,我已經使用過這個BlueImp

相關問題