Handled sync upload

1 Answer 26 Views
AsyncUpload
Omar
Top achievements
Rank 1
Veteran
Iron
Omar asked on 20 Dec 2021, 04:05 PM | edited on 20 Dec 2021, 04:39 PM

Hi,

I am trying to perform an upload with no post back, so I am using the handler. Telerik  v4.0.30319

The code works, but for some reason it split the file and upload only 2MB of it. 

 public class myHandler : AsyncUploadHandler, System.Web.SessionState.IRequiresSessionState
    {

        protected override IAsyncUploadResult Process(UploadedFile file, HttpContext context, IAsyncUploadConfiguration configuration, string tempFileName)
        {
            
            string targetFolder = context.Server.MapPath("~/Uploads/");
            string fileName = file.GetName();

            file.SaveAs(targetFolder + fileName);

            return CreateDefaultUploadResult<UploadedFileInfo>(file);
        }


    }

JS code

  <script type="text/javascript">
        function OnClientFileUploadFailed(sender, args) {

        }

        function OnClientValidationFailed(sender, args) {

        }
        var gridfileName = '';
        function OnClientFilesUploaded(sender, args) {
           
            GetgridIDfieldName(gridfileName);
        }
        function OnClientFilesUploading(sender, args) {
         
            gridfileName=args.get_fileName();
        }
    </script>

 

                                        <telerik:RadAsyncUpload  
                                            ID="RadAsyncUpload1"
                                            OnClientFileUploadFailed="OnClientFileUploadFailed"
                                            OnClientValidationFailed="OnClientValidationFailed"
                                            OnClientFilesUploaded="OnClientFilesUploaded"
                                            OnClientFileUploading="OnClientFilesUploading"
                                            HttpHandlerUrl="~/myHandler.ashx"
                                            TargetFolder="~/Uploads"
                                            DisableChunkUpload="true"
                                            MaxFileSize="10485760"
                                            RenderMode="Lightweight"
                                            runat="server">
                                        </telerik:RadAsyncUpload>

Note: The code do not create temp file at "\App_Data\RadUploadTemp"  it directly upload the file to the Uploads folder.

Any help is much appreciated.

Regards,

Omar

1 Answer, 1 is accepted

Sort by
0
Accepted
Omar
Top achievements
Rank 1
Veteran
Iron
answered on 20 Dec 2021, 05:56 PM

For some reason, it worked perfectly after adding " MaxFileInputsCount="1"", But I do not know why.

Tags
AsyncUpload
Asked by
Omar
Top achievements
Rank 1
Veteran
Iron
Answers by
Omar
Top achievements
Rank 1
Veteran
Iron
Share this question
or