Validating Multiupload file after uploaded and Return Success or Error

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Validating Multiupload file after uploaded and Return Success or Error

    I need to use multiupload component and add validation function OnFileUploaded.
    If the validation is true, than the uploaded file success.
    Else its error (even if upload is success, but if the validation is false than it show error).

    How can I do this?

    My current code is a copy to the example this.

    I try to change some code.

    I remove OnFileUpload event from <ext:MultiUpload> component.
    then on UploadComplete listener I set to my javascript handler completeRecord.
    <Listeners>
       <SwfUploadLoadFailed Fn="loadFailed" />
       <FileSelected Fn="fileSelected" />
       <UploadStart Handler="updateRecord(file.id, 'status', 'Sending');" />
       <UploadProgress Handler="updateRecord(file.id, 'progress', bytesComplete / bytesTotal);" />
       <UploadComplete Handler="completeRecord(file.id);" />
       <UploadAborted Handler="updateRecord(file.id, 'status', 'Aborted');" />
       <UploadRemoved Handler="var store = this.up('grid').store; store.remove(store.getById(file.id));" />
       <UploadError Fn="uploadError" />
       <FileSelectionError Fn="fileSelectionError" />
    </Listeners>
    this is my completeRecord
            var completeRecord = function (id, name) {
                updateRecord(id, 'progress', 1);
                updateRecord(id, 'status', 'Validating');
    
                if (CompanyX.ValidateFile(id) == true) {  //this is a Direct Method for validation
                    updateRecord(id, 'status', 'Success');
                } else {
                    updateRecord(id, 'status', 'Error');
                }
            };
    This is my direct method validation function (I'm using VB code but I can understand C# code if VB not supported).
        <DirectMethod>
        Public Function ValidateFile(id As Integer) As Boolean
            Try
                'Request.Files.Count = 0 HERE I don't know how to get Uploaded file here
                'Some Validation HERE
    
                ValidateFile = True
            Catch ex As Exception
                Ext.Net.X.Msg.Alert("Error", ex.Message).Show()
                ValidateFile = False
            End Try
        End Function
    My problem is I can't get the uploaded data using Request.Files from the direct method called.
    Anyone can help me to solve this? Maybe I'm missing something or any other suggestion is welcome.
    Last edited by Kuro13; Dec 14, 2016 at 10:46 AM.

Similar Threads

  1. Replies: 24
    Last Post: Dec 19, 2015, 11:01 AM
  2. [CLOSED] Get uploaded file name and file path server side.
    By speedstepmem4 in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Jul 31, 2014, 11:24 AM
  3. MultiUpload Last file uploaded event
    By stebag in forum 2.x Help
    Replies: 1
    Last Post: Jan 19, 2014, 1:28 PM
  4. Replies: 5
    Last Post: Oct 07, 2013, 2:44 PM
  5. How to access/read from uploaded file
    By KBorkiewicz in forum 2.x Help
    Replies: 3
    Last Post: Nov 21, 2012, 4:32 PM

Tags for this Thread

Posting Permissions