Question

Decided to remove FileUpload and try AsyncFileUpload - apart from having to use triggers to make the page post back fully and leave the user wondering what was happening FileUpload worked without a hitch.... Can't for the life of me get AsyncFileUpload to work and HasFile is always false. Any ideas? Somewhere I do have an Ajax uploader built by, I think, an Italian developer, that worked quite well but there was a lot of messing around saving the file to the server first then deleting it.

Thank you.

 vCmd.Parameters.AddWithValue("@Status_ID", 1)
        vCmd.Parameters.AddWithValue("@Customer_ID", CustomerID)
        vCmd.Parameters.AddWithValue("@Application_Description", vDescription)
        If AsyncFileUpload1.HasFile Then
            Dim vLen As Integer = AsyncFileUpload1.PostedFile.ContentLength
            Dim vByte(vLen - 1) As Byte
            AsyncFileUpload1.PostedFile.InputStream.Read(vByte, 0, vLen)
            vCmd.Parameters.AddWithValue("@Documents_Main", vByte)
            vCmd.Parameters.AddWithValue("@Flag_DocumentLoaded", 1)
        Else
            vCmd.Parameters.AddWithValue("@Flag_DocumentLoaded", 0)
        End If
        vCmd.Parameters.AddWithValue("@Contractor_Name", vContractorName)
        vCmd.Parameters.AddWithValue("@Contractor_Address", vContractorAddress)
        vCmd.Parameters.AddWithValue("@Contractor_Licence", vContractorLicence)
        vCmd.Parameters.AddWithValue("@Contractor_Phone", vContractorPhone)
        vCmd.Parameters.AddWithValue("@Reference_One", vReferenceOne)
Was it helpful?

Solution

Managed finally to get it to work

Add a handler for the UploadedComplete event

AddHandler AsyncFileUpload1.UploadedComplete, AddressOf FileUploaded

Capture the bytes in the event

Private Sub FileUploaded(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs)
    Try

        If AsyncFileUpload1.HasFile Then
            Session("UploadedPDF") = AsyncFileUpload1.FileBytes
        End If


    Catch ex As Exception
        EmailError(ex.ToString, "25")

    End Try
End Sub

Upload the file to the DB if it is there

 If Not Session("UploadedPDF") Is Nothing Then
            vCmd.Parameters.AddWithValue("@Update_Document", Session("UploadedPDF"))
        End If
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top