asp.net mvc ajax上传解决方案?

前端之家收集整理的这篇文章主要介绍了asp.net mvc ajax上传解决方案?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在寻找好的ajax上传解决方案.

我试着用

1)SWFUpload(它工作正常,但仅适用于一个文件)

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

我想问你使用进度条上传多个文件时使用了哪些解决方案?

解决方法

我个人喜欢 Valums Ajax Upload.

更新:

正如评论部分所要求的,这是一个如何与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 });
    }
}

查看(〜/ Views / Home / 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>
原文链接:https://www.f2er.com/aspnet/248052.html

猜你在找的asp.Net相关文章