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

Kendo Mobile mvvm upload

1 Answer 147 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Shaun
Top achievements
Rank 1
Shaun asked on 13 May 2014, 03:10 PM
Hello,

I am working on a kendo mobile app built with mvc and mvvm.
I have a form with some fields ( a model ) and an upload control which allows one or more files to be uploaded.
On form submit I go to a viewmodel method which validates the form and if everything is ok then it creates a json object and passes that to an mvc controler for final processing. At this stage I also need to attach the information of the uploaded files. For details sake this is an email form and I want the file uploaded to become an attachment. 
I cannot add the uploaded file information on form submit. Is there an example which shows how this works ?
I've seen a number of ways but none dealing with this process.

I tried an async manner for the file upload unfortunately that does not work very well due to the fact that it triggers on upload. Of course this only sends back the uploaded file and then I am supposed to store it somewhere apparently. I don't like this approach mainly because at the upload stage I may not even have the other form information. I need this to work properly, together, so the form validates then takes the uploaded file information and posts everything to the controller in one go not in a separate way. 

How can this be achieved ?

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 15 May 2014, 11:00 AM
Hi Stuart,


If the synchronous version of the Upload widget is used and it is part of the form, it does not distinguish from regular input type="file" elements. The selected files will be part of the form submit information, so you could use the submit event of the form in order to validate the information and process the submit as usual. In general, in this case, if you are able to implement the scenario without the Upload widget, but with a regular input type="file", there should not be a difference when implementing our widget. Let me know if that is not the case.

As for the case of asynchronous upload, you could set the autoUpload option to false. This way the upload will be triggered through a button click. Additionally you could use the upload event handler to attach the additional data to the uploaded file.

I hope this information helps. Have a great day!

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Upload
Asked by
Shaun
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or