Kendo Mobile mvvm upload

2 posts, 0 answers
  1. Shaun
    Shaun avatar
    10 posts
    Member since:
    Dec 2010

    Posted 13 May 2014 Link to this post


    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 ?

  2. Dimiter Madjarov
    Dimiter Madjarov avatar
    2310 posts

    Posted 15 May 2014 Link to this post

    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!

    Dimiter Madjarov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top