問題描述
我正在處理 ASP.NET 中的文件上傳.我使用了 <input type=file id=upload>
和 <input type=button id="btnupload" value="File Upload">
I am working on a file upload in ASP.NET. I used <input type=file id=upload>
and <input type=button id="btnupload" value="File Upload">
我想用 JavaScript 上傳文件.更新面板不起作用,我不希望它回發并刷新頁面.
I want to upload the file in JavaScript. The update panel does not work, I do not want it to postback and refresh the page.
謝謝,但是如果您有與 javascript 中的 fileUpload 相關的代碼,請發送給我.請幫我.
thanks but If you have code related to fileUpload in javascript then send me. please help me.
推薦答案
可以使用 jQuery 和 jQuery 表單插件.我在幾個項目中使用了這個組合,我沒有問題,即使是大文件(10mb)
You can use jQuery and jQuery form plugin. I used this combination for few project and i had no problems, even for big files (10mb)
<form action="form.asp" method="post">
.......
</form>
$('form').submit(function(){
$(this).ajaxSubmit(function(data){
$('#updateDiv').html(data); // or append/prepend/whatever
})
return false
})
當然,表單的操作會返回您需要更新的內容.您可能需要添加一些額外的函數來處理錯誤,但這應該可以正常工作
Ofcourse, the action of the form will return what you need to update. You may want to add some extra functions to handle errors, but this should work fine
這篇關于如何在沒有回發的情況下使用 JavaScript 上傳文件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!