This is a migrated thread and some comments may be shown as answers.

Asyncfileupload lose the data if your didnt initiate postback right after the upload is completed

3 Answers 173 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Moe
Top achievements
Rank 1
Moe asked on 26 Jul 2012, 04:51 PM
Hi, 

I am using Asyncfileupload, and it work perfect but i have a case where the asyncfileupload fail to store the images after initiating postback. below is the scenario

1- fill the form
2- browse the images,... images are uploading
3- wait for one minute then click submit to save the images, save the form data

result:
1- the form has been saved successfully
2- images never saved, it is like you didnt upload any images at all



3 Answers, 1 is accepted

Sort by
0
Accepted
Plamen
Telerik team
answered on 31 Jul 2012, 12:19 PM
Hello,

 
Would you please let us know if this issue can be observed with the code of any of our online demos and under which browser it can be reproduced? this way we will be able to inspect it deeply and be more helpful.

Greetings,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Moe
Top achievements
Rank 1
answered on 31 Jul 2012, 11:10 PM

<script language="javascript" type="text/javascript">
    /////////////////////////// BEGIN //////////////////////////////////
    $(function () {
 
    function fileSelected(sender, args) {
        // submit button disabled
        $('#btnSubmit').attr('disabled', true);
    };
 
    function fileUploaded(sender, args) {
        // submit button enabled
        $('#btnSubmit').attr('disabled', false);
    };
     
</script>



<
label>Images (Recommended 8 images at a time / Max size 4 MB each image) <a href="/learnresize" target="_blank">Learn to resize</a></label>
                 
<telerik:RadAsyncUpload MaxFileInputsCount="8"  ID="RadAsyncUpload_Images" ToolTip="Choose images to upload"
    OnClientFilesUploaded="fileUploaded" OnClientFilesSelected="fileSelected"
    MultipleFileSelection="Automatic" AllowedFileExtensions="jpeg,jpg,gif,png" MaxFileSize="9145728"
    TargetFolder="files" runat="server">
</telerik:RadAsyncUpload>


The server side is below:

Imports System.IO
 
Public Class shareAsyncUpload
    Inherits System.Web.UI.Page
    Dim m_arrFilesList As New List(Of String)
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
    End Sub
 
    Private Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
        submit()
        Response.Redirect("/members/account", False)
    End Sub
 
    Function submit()
        Try
 
            Using Context As New PBEntities
 
                Dim m_User As MembershipUser = Membership.GetUser(Page.User.Identity.Name)
                Dim m_id As New Data.Objects.ObjectParameter("ImgID", GetType(Integer))
                Context.addImageMaster(Server.HtmlEncode(txttitle.Text), ddlcountries.SelectedValue, Server.HtmlEncode(txtRemarks.Text), Date.Now, False, _
                                       m_User.ProviderUserKey, 0, 0, m_id)
          
                For i As Integer = 0 To m_arrFilesList.Count - 1
                    If i = 0 Then ' the first image is the default one
                        Context.AddImageDetails(m_arrFilesList.Item(i), m_id.Value, True, True, Date.Now)
                    Else
                        Context.AddImageDetails(m_arrFilesList.Item(i), m_id.Value, True, False, Date.Now)
                    End If
                Next i
            End Using
 
 
        Catch ex As Exception
            objShared.logOperation(7, ex.Message, Request.RawUrl, "", Page.User.Identity.Name, Date.Now)
        End Try
        '  RadAsyncUpload_Images.MaxFileSize
    End Function
 
    Private Sub RadAsyncUpload_Images_FileUploaded(sender As Object, e As Telerik.Web.UI.FileUploadedEventArgs) Handles RadAsyncUpload_Images.FileUploaded
 
        Dim m_MasterPath = HttpContext.Current.Server.MapPath(objShared.GetWord("key_file_Path"))
        Dim m_MasterPathThumbs = HttpContext.Current.Server.MapPath(objShared.GetWord("key_file_Path_thumb"))
        Dim m_fileExt = e.File.GetExtension()
        Dim m_RndFileName = objShared.getGuid
        Dim m_NewFileName = m_RndFileName + m_fileExt
 
        ' if the file name already exist, then append a random number to it
        If System.IO.File.Exists(m_MasterPath + m_NewFileName) Then
            m_NewFileName = CStr(m_RndFileName + "_" + objShared.GenerateRandomNumber() + m_fileExt)
        End If
 
        Try
            ' Upload orginal file
            e.File.SaveAs(Path.Combine(m_MasterPath, m_NewFileName))
            ' Resize and save orginal images
            ImageHelper.SavetoDisk(m_MasterPath + m_NewFileName, HttpContext.Current.Server.MapPath(objShared.GetWord("key_file_Path_thumb_171x105")) + m_NewFileName, 171, 171, m_fileExt)
            ImageHelper.SavetoDisk(m_MasterPath + m_NewFileName, HttpContext.Current.Server.MapPath(objShared.GetWord("key_file_Path_thumb_99x72")) + m_NewFileName, 65, 65, m_fileExt)
            ImageHelper.SavetoDisk_WhiteSpace(m_MasterPath + m_NewFileName, m_MasterPathThumbs + m_NewFileName, 472, 472, m_fileExt)
 
            ' Add file name to a list of string
            m_arrFilesList.Add(m_NewFileName)
 
        Catch ex As Exception
            objShared.logOperation(7, ex.Message, Request.RawUrl, "", Page.User.Identity.Name, Date.Now)
        End Try
 
    End Sub
End Class
Please note this issues occurs in all browser, so it is not browser issue 
0
Genady Sergeev
Telerik team
answered on 28 Nov 2012, 03:29 PM
Hello Moe,

This is actually a bug in RadAsyncUpload, whose workaround is described here. (under Q2 2010 (Version 2011.2.713) heading). The good news are that the issue is fixed for version Q3 2011 and forth.

Kind regards,
Genady Sergeev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
AsyncUpload
Asked by
Moe
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Moe
Top achievements
Rank 1
Genady Sergeev
Telerik team
Share this question
or