7

良い ajax アップロード ソリューションを探しています。

使ってみた

1) SWFUpload (正常に動作しますが、1 つのファイルに対してのみ)

2) Jquery Ajax プラグイン (動作せず、IE のプログレスバーをサポートしていません)

プログレスバーを使用して複数のファイルをアップロードするために使用するソリューションは何ですか?

4

1 に答える 1

14

個人的には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>
于 2011-10-27T07:35:38.667 に答える