zoukankan      html  css  js  c++  java
  • 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";
                }  
               
            }
  • 相关阅读:
    Linux下卸载Oracle 11g
    Oracle
    Oracle 数据库启动与关闭
    1-centos7安装oracle 11gR2
    0-windows7硬盘安装centos7
    查重 查重复记录 删除重复记录
    用户情景快速指南
    智能led灯具HMI(无线终端参数设置界面)
    LBDP-Z APP在线升级指南
    智能led灯具HMI(用户模块及管理员模块)操作说明
  • 原文地址:https://www.cnblogs.com/sky-net/p/3853391.html
Copyright © 2011-2022 走看看