asp.net mvc的AJAX上传解决方案? [英] asp.net mvc ajax upload solution?

查看:180
本文介绍了asp.net mvc的AJAX上传解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找好的Ajax上传的解决方案。

I'm looking for good ajax upload solution.

我试图用

1)SWFUpload的(它做工精细,但只有一个文件)

1) SWFUpload (it is work fine but only for one file)

2)的Jquery的Ajax插件(它不工作,它不支持在IE进度)

2) Jquery Ajax plugin (it's not working and it doesn't support progressbar in IE)

我想请教各位有什么解决方案,你使用的上传与进度条的多个文件?

I'd like to ask you what solutions do you use for Uploading multiple files with progress bar?

推荐答案

我个人喜欢 Valums阿贾克斯上传

更新:

由于在评论部分要求这里有一个如何这可能是与ASP.NET MVC中使用的例子。

As requested in the comments section here's an example of how this could be used with ASP.NET MVC.

控制器:

public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    [HttpPost]
    public ActionResult Upload(string qqFile)
    {
        // The upload action will be called by the client control
        // for each file that was selected by the user for upload

        var path = Server.MapPath("~/App_Data");
        var file = Path.Combine(path, qqFile);
        using (var output = System.IO.File.Create(file))
        {
            Request.InputStream.CopyTo(output);
        }
        return Json(new { success = true });
    }
}

查看(〜/查看/主页/ Index.cshtml

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Ajax Upload demo with ASP.NET MVC</title>
    <link href="@Url.Content("~/Content/fileuploader.css")" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="file-uploader">       
        <noscript>          
            <p>Please enable JavaScript to use file uploader.</p>
            <!-- or put a simple form for upload here -->
        </noscript>         
    </div>

    <script src="@Url.Content("~/Scripts/fileuploader.js")" type="text/javascript"></script>
    <script type="text/javascript">
        var uploader = new qq.FileUploader({
            element: document.getElementById('file-uploader'),
            action: '@Url.Action("Upload", "Home")'
        });    
    </script>
</body>
</html>

这篇关于asp.net mvc的AJAX上传解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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