views:

273

answers:

2

Hello, I'm trying to implement uploadify, but for some reason I'm failing at getting the event onComplete.

My code looks like this so far and the uploadify can upload the files to the folder that I've selected.

Sys.Application.add_load(AddAdvertise);
function AddAdvertise() {
    $('.flUploadImage').uploadify({
        'uploader': '/Templates/Public/Images/BuyAndSell/uploadify.swf',
        'script': 'http://localhost:81/Templates/Public/HttpHandler/Upload.ashx',
        'cancelImg': '/Templates/Public/Images/BuyAndSell/cancel.png',
        'auto': true,
        'folder': "/" + $('#<%=hdnGUID.ClientID %>').attr('Value'),
        'method': 'POST',
        onProgress: function() {
            alert("test1");
        }
        ,
        onComplete: function() {
            alert("test");
        }
    });

}

and my upload handler

    public void ProcessRequest(HttpContext context)
    {
        HttpPostedFile oFile = context.Request.Files["Filedata"];
        if (oFile != null)
        {
            string folder =HttpContext.Current.Server.MapPath( mainFolder + @context.Request["folder"]);
            if (System.IO.Directory.Exists(folder))
            {
                oFile.SaveAs(folder + "/"+oFile.FileName);
            }
            else
            {
                DirectoryInfo dir = Directory.CreateDirectory(folder);
                if(dir != null)
                {
                    oFile.SaveAs(folder + "/" + oFile.FileName);    
                }
            }                

        }
    }

What I'm missing?

A: 

This issue is resolved previously here.

Also, you can find a demo of uploadify implementation in my blog.

Technowise
Thanks for the links. What I was missing was setting the return value when the upload had been succesfully.So the following code in the handler fixed my issue:context.Response.StatusCode = 200;
Daniel
A: 

I had this problem, and I solved it by returning some value from the server function.

Bryan