zoukankan      html  css  js  c++  java
  • ___简单的MVC单个图片上传预览

    js:


    $("#btnImg").click(function () {
    $("#form0").ajaxSubmit({
    url: "/Student/Img",
    type: "post",
    success: Math,
    })
    return false;
    })
    function Math(data) {
    $("#Imgurl").val(data);
    $("#result").html(" <img src='" + data + "' style='80px;height:60px' />")
    }

    html:

    td>头像</td>
    <td><input id="ImgMath" type="file" name="ImgMath" /><input id="btnImg" type="button" value="预览" /></td>
    @Html.Hidden("Imgurl")
    <td><span id="result"></span></td>

    coller:

    [HttpPost]
    public ActionResult Img()
    {
    var Maph = Request.Files["ImgMath"];
    string ImgPath ="/Content/img/" + Maph.FileName;
    string Ser_Img = Request.MapPath(ImgPath);
    Maph.SaveAs(Ser_Img);
    return Content(ImgPath);
    }

  • 相关阅读:
    python笔记目录
    Django 的View(视图)系统
    051_Bootstrap 框架
    050_jQuery 事件
    049_jQuery 操作标签
    048_jQuery
    016-递归函数
    047_BOM_DOM
    046_JS
    045_CSS
  • 原文地址:https://www.cnblogs.com/100234ltf/p/9872657.html
Copyright © 2011-2022 走看看