file upload using knockout js

后端 未结 5 2718
故里飘歌
故里飘歌 2021-02-20 04:39

File upload not working using knockout js. I have tried with below code but not working. Please mention where I am doing wrong.

This is my file control and button. I am

5条回答
  •  走了就别回头了
    2021-02-20 05:21

    
    
    function ()
    {
        var files = $("#FileName").get(0).files;
        var data = new FormData();
        for (var x = 0; x < files.length; x++) {
            data.append("file" + x, files[x]);
        }
    
        $.ajax({
            type: "POST",
            url: '/api/Controller' + '/?id=' + id ),
            contentType: false,
            processData: false,
            data: data,
            success: function (result) {},
            error: function (xhr, status, p3, p4) {}
        });
    }
    

提交回复
热议问题