File uploads being duplicated. (Uploader1_FileUploaded event firing multiple times per file?)

Last post 12-21-2010, 6:41 AM by johansec. 2 replies.
Sort Posts: Previous Next
  •  12-16-2010, 2:07 PM 65388

    File uploads being duplicated. (Uploader1_FileUploaded event firing multiple times per file?)

    Hi,
     
    I am using AjaxUploader vers.  3.020100818.   Upon uploading to the web server I am using the  Uploader1_FileUploaded event to write the file to a Sql Server table.  
     
    It is working fine most of the time, but all too often it will write duplicate copies of the exact same file to the database.  When it does this, most of the time it is only 1 extra copy, but sometimes it may do it 3, 7 or even 9 times.
     
    Have you had any issues with the Uploader_FileUploaded event firing more than once for an idividual file upload?   I don't believe the file is actually being uploaded multiple times because the timestamps are usually within a second or so for each copy, but am guessing the event is firing more than once causing multiple writes to the database.  Please help.
     
    Thanks, Chip
  •  12-16-2010, 7:52 PM 65391 in reply to 65388

    Re: File uploads being duplicated. (Uploader1_FileUploaded event firing multiple times per file?)

    Hi johansec,
     
    Try event UploadCompleted
     
        protected void uploader1_UploadCompleted(object sender, UploaderEventArgs[] args)
        {
            for (int i = 0; i < args.Length; i++)
            {
                args[i].CopyTo("~/photos/"+args[i].FileName);
                //save info into database
            }
        }
     
    Regards,
     
    Ken
  •  12-21-2010, 6:41 AM 65487 in reply to 65391

    Re: File uploads being duplicated. (Uploader1_FileUploaded event firing multiple times per file?)

    Intial feedback from users that were experiencing duplicate uploads would indicate that moving the database save from the Uploader1_FileUploaded event to the Uploader1_UploadCompleted event as suggested has solved this problem. 

    Thanks for your help.
View as RSS news feed in XML