Possible to Post Files to Controller via jQuery instead of through the .Save Action?

2 posts, 0 answers
  1. Landon
    Landon avatar
    66 posts
    Member since:
    Nov 2010

    Posted 29 Oct 2013 Link to this post

    Hi,

    I'm looking to use the Kendo Upload control to Import vCards onto a Contact Creation page. Since I want to return a PartialView, and populate a Div's .html attribute, I'd like to do this as a jQuery Post like I've outlined below:
    @(Html.Kendo().Upload()
         .Name("vCard")
         .Async(a => a
             .Save("UploadContact", "Contacts") /*Don't really need this if I can post via jQuery */
             .AutoUpload(true)
             )
         .Events(events => events
             .Select("onSelect")
             .Upload("onUpload")
             )
         .ShowFileList(false)
         .Multiple(false)
         )
    function onUpload(e) {
            var upload = $("#vCard").data("kendoUpload");
            var files = upload.files;
     
            var serialized = "vCard=" + files;
            $.post("/Contacts/UploadContact/", serialized, function (returnHtml) {
                //alert(returnHtml);
                $("#ContactContainer").html(returnHtml);
            });
    My issue is that I am constantly getting a null object when posting to /Contacts/UploadContact using jQuery.

    Is there any way to pass the entire file list (including FileStream) back to the controller from jQuery like I've outlined in the "onUpload" method?

    Any help would be greatly appreciated.

    Thanks,
    Landon
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 30 Oct 2013 Link to this post

    Hello Landon,


    The Upload widget does not support such scenario. If you would like to manually implement file upload functionality, you could find additional information on the internet.

     

    Regards,
    Dimiter Madjarov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
Back to Top