如何上传使用JavaScript没有回传文件? [英] How can I upload a file using JavaScript without a postback?

查看:117
本文介绍了如何上传使用JavaScript没有回传文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作在ASP.NET文件上传。我用<输入类型=文件ID =上传> <输入类型=键ID =btnuploadVALUE =文件上传&GT ;

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 code,然后送我。请帮帮我。

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,表单的动作会回到你需要更新的东西。您可能需要添加一些额外的功能来处理错误,但是这应该工作正常。

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没有回传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆