Dec 14, 2016, 10:34 AM
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.
Anyone can help me to solve this? Maybe I'm missing something or any other suggestion is welcome.
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.