0

I use uplodify 3.1 to upload multiple files in asp.net. it allows to select mutiple files and uploads them. but my probem is that i have to click upload button for each item. (aouto attribute is set to false) here is my code:

<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>

and the code in the ashx file:

<%@ 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;
        }
    }
}

please help.

osmanraifgunes
  • 1,438
  • 2
  • 17
  • 43
  • 1
    11 views 0 answers. should be a record. – osmanraifgunes Jul 02 '12 at 21:10
  • You might look at: http://stackoverflow.com/questions/2501037/getting-uploadify-working-in-c-sharp – NotMe Jul 02 '12 at 22:17
  • I saw that topic before. But my problem is different. I know how to use uplodify. I want to use version 3.2 to have a secure upload. When I set the auto property to true there is no problem. The problem is that: "I HAVE TO CLICK UPLOAD BUTTON FOR EACH PHOTO TO UPLOAD MULTIPLE FILES WHEN I SET THE AUTO PROPERTY TO FALSE." – osmanraifgunes Jul 03 '12 at 19:26

1 Answers1

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>
NotMe
  • 87,343
  • 27
  • 171
  • 245
  • Thanks for your answer, but this time it doesn't uploads anything. When I control the syntax from the uplodify documentation there is no parameter passed by this function. There should be a problem with this. – osmanraifgunes Jul 04 '12 at 18:56