0

uplodify 3.1 を使用して、asp.net に複数のファイルをアップロードします。複数のファイルを選択してアップロードできます。しかし、私の問題は、アイテムごとにアップロードボタンをクリックする必要があることです。(aauto 属性は false に設定されています) ここに私のコードがあります:

<head>
<script src="Scripts/jquery.js" type="text/javascript"></script>
    <script src="Scripts/jquery.uploadify-3.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(window).load(
    function () {
        $("#<%=FileUpload1.ClientID%>").uploadify({
            'swf': 'Scripts/uploadify.swf',
            'uploader': 'Upload.ashx',
            'fileTypeDesc': 'Image Files',
            'fileTypeExts': '*.jpg;*.jpeg;*.gif;*.png',
            'multi': true,
            'formData': { 'galerisi': '<%=Session["galeriId"]%>' },
            'auto': false,
            'buttonImage': 'Styles/images/btnYorumEkle.png',
            'buttonText': 'Dosya seç'

        });
    }
);
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div style="float: left;">
            <asp:FileUpload ID="FileUpload1" runat="server" />
        </div>
        <div style="left: 136px; position: absolute; top: 18px;">
            <a class="blueButton" href="javascript:$('#<%=FileUpload1.ClientID%>').uploadify('upload')">
                Yükle</a>
        </div>
        <div style="left: 205px; position: absolute; top: 18px;">
            <a class="blueButton" href="javascript:$('#<%=FileUpload1.ClientID%>').fileUploadClearQueue()">
                Temizle</a>
        </div>
    </div>
    </form>
</body>

ashx ファイル内のコード:

<%@ WebHandler Language="C#" Class="Upload" %>

using System;
using System.Web;
using System.IO;

using System.Collections.Generic;
using System.Web.SessionState;
public class Upload : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{


    galeriIslemleri galeriler = new galeriIslemleri();
    Tools tollar = new Tools();


    public void ProcessRequest(HttpContext context)
    {

        context.Response.ContentType = "text/plain";
        context.Response.Expires = -1;


        try
        {
                string galeriKlasoru = context.Request["galerisi"].ToString();

                var db = Tools.DBBaglanti();
                HttpPostedFile postedFile = context.Request.Files["Filedata"];

                string savepath = "";
                string tempPath = "";
                tempPath = "images/galeriler/" + galeriKlasoru;

                savepath = context.Server.MapPath(tempPath);

                string filename = postedFile.FileName;
                if (!Directory.Exists(savepath))
                    Directory.CreateDirectory(savepath);

                postedFile.SaveAs(savepath + @"\" + filename);
                context.Response.Write(tempPath + "/" + filename);
                context.Response.StatusCode = 200;


                galeriResimleri resimler = new galeriResimleri();
                resimler.galeriId = Convert.ToInt32(galeriKlasoru);
                resimler.resim = filename;
                db.galeriResimleris.InsertOnSubmit(resimler);
                db.SubmitChanges();

        }
        catch (Exception ex)
        {
            context.Response.Write("Error: " + ex.Message);
        }


    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

助けてください。

4

1 に答える 1

0

Reference: http://www.uploadify.com/documentation/uploadify/upload/

It seems that if Auto is set to false then you have to pass an asterisk '*' as the fileid to upload all of the files in the queue. For example:

<a class="blueButton" href="javascript:$('#%=FileUpload1.ClientID%>').uploadify('upload','*')">Yükle</a>
于 2012-07-03T21:02:04.867 に答える