Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m using Uplodify for image upload..in a folder
it upload duplicate image..means many image with same name
i m want to upload file only one time..if i try next time it will nt upload i want to do this..

how can i solve this problem

help me..???
Posted

Im assuming you are referring to this[^] tool.
Although some people here who might be using Uploadify can answer your question, I suggest you also post your question on their forum[^]. This makes more sense for me since 1. You post a question to a community of developers who use the product and 2. You get to report bugs or suggest possible enhancements for the tool.
 
Share this answer
 
v2
Hi!

I did excactly this.

in my ASPx File JavaScript Code I use
JavaScript
$("#UPLOAD_BUTTON").uploadify({
                  'buttonClass'   : "ui-icon ui-icon-plus",
                  'swf'            : '/web/uploader/uploadify.swf',                  
                  'uploader'       : '/web/uploader/Uploadify.ashx?ASPSESSID=<% =Session.SessionID %>',
                  'cancelImage'    : '/web/uploader/uploadify-cancel.png',
                  'folder'         : '/uploads',
                  'multi'          : true,
                  'auto'           : true,
                  'checkExisting'  : '/web/uploader/Uploadify.ashx?check=true',
                  'queueID'        : "UploadFilesQueue",
                  'buttonText'     : ' ',          
                  'hideButton'     : true,  
                  'fileTypeExts'   : '*.*',
                  'fileTypeDesc'   : 'Alle Dateien',
                  'onQueueComplete': function(event,data) {                      
                  },
                  postData : {
                    "stepID" : $("#lblStepID").text(),
                    "ASPSESSID" : "<% =Session.SessionID %>",                    
                  }
              });


you need to pass the SessionID as a parameter and grab it in the Global.asax File or you will create a new ASP.NET session on every Upload.

In the jquery.uploadify.js File you need to find this function and modify it
JavaScript
function onUploadStart(file)


There you can react on the Returncode from you Upload-ASHX file.

I use different return codes for different conditions like
ReturnCode=1 -> File allready Exists
ReturnCode=2 -> File is to Big
....
 
Share this answer
 
Comments
nawabprince 2-Mar-12 5:36am    
Thanks WB Please Provide me code for that uplodify.Ashx...
Regards Nawab
this is the (a bit modified) content of my upload.ashx file

C#
<![CDATA[<%@ WebHandler Language="C#" Class="esp.Web.Upload" %>]]>

using System;
using System.Web;
using System.IO;
using System.Web.Util;
using System.Web.SessionState;
using System.Web.Configuration;

using System.Collections.Generic;

using esp.Web.uploader;
using log4net;

namespace esp.Web {
    public class Upload : IHttpHandler, IRequiresSessionState {

        public void ProcessRequest(HttpContext context) {
            context.Response.ContentType = "text/plain";
            context.Response.Expires = -1;
            var  log = LogManager.GetLogger(typeof(Upload));
            log.Debug("Upload: ProcessRequest");
            try {                                
                var usr = ValidateSession(context, log);
                if( usr != null ) {
                    if( context.Request.Params["check"] != null ) {
                        String filename = context.Request.Params["filename"];
                        TestForUpload(context, log, usr, filename);
                    } else {
                        UploadFile(context, log, usr);
                    }
                } else {
                    context.Response.Write("Error: I'm a Teapot!");
                    context.Response.StatusCode = 418;
                }
            } catch( Exception ex ) {
                log.Error(ex.ToString( ));
                context.Response.Write("Error: " + ex.Message);
                context.Response.StatusCode = 500;
            }
        }

        protected void TestForUpload(HttpContext context, ILog log, <myuserclass> usr, String filename) {
            IUploadFileDispatch disp = (IUploadFileDispatch)context.Session["FILE_DISPATCH"];
            HttpRuntimeSection section = System.Configuration.ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection;
            long fileSize = Int64.Parse(context.Request.Params["filesize"]);
            if( fileSize > section.MaxRequestLength ) {
                context.Response.Write("2");
                context.Response.StatusCode = 200;
            } else {
                if( disp.ValidateFile("", filename) ) {
                    context.Response.Write("0");
                    context.Response.StatusCode = 200;
                } else {
                    context.Response.Write("1");
                    context.Response.StatusCode = 200;
                }
            }
        }

        protected void UploadFile(HttpContext context, ILog log) {
                       
        }

        public bool IsReusable {
            get {
                return false;
            }
        }

        public <myuserclass> ValidateSession(HttpContext context, ILog  log) {            
            
        }

    }
}
</myuserclass></myuserclass>
 
Share this answer
 
Comments
nawabprince 2-Mar-12 6:22am    
Thanks alot WB

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900