MVC无刷新上传图片并显示

@{
    ViewBag.Title = "Home Page";
}
<script src="../../Scripts/swfobject.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.uploadify.v2.1.4.js" type="text/javascript"></script>
<link href="../../Content/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(document).ready(function () {
        $("#uploadify").uploadify({
            uploader: /content/uploadify.swf,
            script: /Home/Upload,
            cancelImg: /content/cancel.png,
            folder: UploadFile,
            queueID: fileQueue,
            auto: false,
            multi: true,
            onComplete: function (event, ID, fileObj, response, data) {

                $(#div_img).after("&nbsp;&nbsp;&nbsp;<img src=" + response + " alt=‘‘ height=‘100‘ width=‘100‘ />")

            }
        });
    });  
</script>
<div id="div_img">
</div>
<div>
    <div id="fileQueue" style="text-align: center">
    </div>
    <input type="file" name="uploadify" id="uploadify" />
    <p>
        <a href="javascript:$(‘#uploadify‘).uploadifyUpload()">上传</a>&nbsp; <a href="javascript:$(‘#uploadify‘).uploadifyClearQueue()">
            取消上传</a>
    </p>
</div>
public string Upload(FormContext from)
        {
            var file = Request.Files["Filedata"];
            string uploadPath = Server.MapPath("~/images/");
            string url = "/images/" + file.FileName;
            if (file != null)
            {                
                file.SaveAs(uploadPath + file.FileName);
             
                return url;//返回保存的地址
            }
            else
            {
                return "0";
            }  
           
        }

MVC无刷新上传图片并显示,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。