UploadCompleted Server-side Event Not Firing

Last post 03-29-2010, 6:42 PM by icastel. 5 replies.
Sort Posts: Previous Next
  •  03-23-2010, 11:51 AM 59601

    UploadCompleted Server-side Event Not Firing

    Hi,
     
    I'm doing a multi-file upload triggered manually, instead of each file uploading as it is selected.  I'm performing some actions server-side on each file by using the FileValidating (e.g. log upload to DB, creating some special folders for each file, then moving the file to that folder).  I want to send a single e-mail notification to the user AFTER ALL files are uploaded, so I'd figured I can do it on Postback, but I get an e-mail for each file:
     
    If Not Page.IsPostBack Then
       
    Session("puUploadCount") = 0
    Else
       ' Do postback stuff here (e.g. provide feedback, send e-mail, etc.)
       ShowOnScreenConfirmation()
       SendNotifications()
    End If
     
    I get one e-mail before anything is uploaded, then one for each uploaded file.  So I tried moving my SendNotifications() call to the UploadCompleted event, but it's not firing at all:
     

    Protected Sub Uploads_UploadCompleted(ByVal sender As Object, ByVal args() As CuteWebUI.UploaderEventArgs) Handles Uploads.UploadCompleted

       SendNotifications()

    End Sub

    What's going on?  How can I resolve this?
     
  •  03-23-2010, 7:33 PM 59607 in reply to 59601

    Re: UploadCompleted Server-side Event Not Firing

    Hi,
     
    If you move the oringinal temp file in FileValidating event, the FileUploaded and the UploadCompleted will not be fired.
     
    Regards,
    Terry
  •  03-24-2010, 11:17 AM 59624 in reply to 59607

    Re: UploadCompleted Server-side Event Not Firing

    Thank you for the clarification Terry.  So, what would you suggest I do? Can I just wait and move the file in the FileUploaded event, then the UploadCompleted will fire? Please advise!
  •  03-25-2010, 4:18 PM 59657 in reply to 59624

    Re: UploadCompleted Server-side Event Not Firing

    Hi guys, any news on this? Please let me know.  Thank you!
  •  03-25-2010, 5:25 PM 59659 in reply to 59657

    Re: UploadCompleted Server-side Event Not Firing

    Dear icastel,
     
    If you have not called args.MoveTo("d:\\test\\"+args.FileName) to move the oringinal temp file in FileValidating event,  FileUploaded method should be called when all files have been uploaded.
     
    Can you post your code here? We will test it.
     
    Regards,
    Eric
     
  •  03-29-2010, 6:42 PM 59726 in reply to 59659

    Re: UploadCompleted Server-side Event Not Firing

    Hi Eric,
     
    My upload code is part of a large web site.  I couldn't post it all here, but I'll try to paste the pertinent sections (hope this helps):
     

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    ShowUserInfo()
    InitializeUploadControl()
    ImportClientSideLibraries()

    If Not Page.IsPostBack Then
       Session("puUploadCount") = 0

    Else
    ShowOnScreenConfirmation() ' Displays some confirmation on screen

    End If

     

    End Sub
     
    Protected Sub InitializeUploadControl()
    Dim MaxFileSize As Int64 = ConfigurationManager.AppSettings("FileUploadMaxKBSize")
    Dim objSupportFuncs As New CloseoutPkgUploadSupport

    Me
    .Uploads.InsertText = "Browse File(s)"
    Me.BulletedList1.Items.Add("The maximum file size accepted is " & (MaxFileSize / 1024).ToString & "MB")Me.Uploads.ManualStartUpload = True
    Me.Uploads.CancelUploadMsg = "Clearing all files from the list ..."
    Me.Uploads.ShowFileIcons = True
    Me.Uploads.CancelAllMsg = "Clear File List"
    Me.Uploads.FileTooLargeMsg = "The file you're trying to upload is too large."
    Me.Uploads.FileTypeNotSupportMsg = "The file type you're attempting to upload is not allowed"
    Me.Uploads.ValidateOption.AllowedFileExtensions = objSupportFuncs.GetAllowedExtensions
    Me.Uploads.TempDirectory = "~/TempFileUploads"
    Me.Uploads.ValidateOption.MaxSizeKB = "50000"

    End Sub

    Protected Sub Uploads_FileValidating(ByVal sender As Object, ByVal args As CuteWebUI.UploaderEventArgs) Handles Uploads.FileValidating

    ' This is fired for each file being uploaed by the AJAX Uploader control
    Dim FileNameOnDisk As String
    Dim TargetDirectory As String
    Dim UploadSavedToDB As Integer
    Dim FundNo As String = Session("puFundInfo").FundNo
    Dim objSupportFuncs As New CloseoutPkgUploadSupport

    Try

    ' Construct file name as it will be stored on disk
    FileNameOnDisk = objSupportFuncs.BuildFileName(FundNo, args.FileName)

    ' Create the folder if it doesn't exist and get the folder path
    TargetDirectory = objSupportFuncs.CreateFolder(FundNo)

    ' Save file metadata to database. The value returned is the integer key of the DB entry.
    ' If 0 is returned, there was an error inserting into the DB
    UploadSavedToDB = objSupportFuncs.SaveUploadToDB(FileNameOnDisk, Session("UID"), FundNo, TargetDirectory, args.FileName, args.FileSize, "", "CloseoutPkg")

    ' Move file to final folder
    args.MoveTo(Replace(TargetDirectory, "\", "\\") & FileNameOnDisk)
    Session(
    "puUploadCount") += 1

    Catch ex As Exception
    ' To do. Handle exceptions

    End Try

     

    End Sub
     

    Protected Sub Uploads_UploadCompleted(ByVal sender As Object, ByVal args() As CuteWebUI.UploaderEventArgs) Handles Uploads.UploadCompleted

        NotifyUsers()  ' Sends e-mail

    End Sub

View as RSS news feed in XML