How to upload image in ASP.NET MVC 4 using ajax or any other technique without postback?

前端 未结 7 1750
鱼传尺愫
鱼传尺愫 2020-12-05 05:40

I am developing a website in MVC 4, where user fill some information and save it to upload. all the information except image is being saved on server using Javascript, Json

7条回答
  •  渐次进展
    2020-12-05 06:27

    $(document).ready(function(){
       var status = $('#status');
    
            $('#frmUpload').ajaxForm({
                beforeSend: function () {
                    if ($("#file").val() != "") {                   
                        $("#progressDiv").show();                    
                    }
                    status.empty();
                },
                success: function () {
                    showTemplateManager();
                },
                complete: function (xhr) {
                    if ($("#file").val() != "") {
                        var millisecondsToWait = 500;
                        setTimeout(function () {                       
                         $("#progressDiv").hide();
                        }, millisecondsToWait);
                    }
                    status.html(xhr.responseText);
                }
            });
    });
    

提交回复
热议问题