zoukankan      html  css  js  c++  java
  • 上传图片2

    <td rowspan="5">
    <!--认证照片显示于此处-->
    <img id="ConfirmimgLogo" src="../Images/photo.jpg" style=" 150px; height: 180px;" />
    </td>

    <td>
    <!--照片上传功能在此处-->
    <input type="file" id="ConfirmFileUpload_Logo" name="ConfirmFileUpload_Logo" style=" 180px" class="easyui-linkbutton" />
    </td>

    //$("#FileUpload_Logo").change(function () {
    $("#FileUpload_Logo").live('change', function () {
    $.ajaxFileUpload({
    url: '/Club/Club.ashx?action=UpLoadImage&random=' + Math.random(),
    secureuri: false,
    fileElementId: 'FileUpload_Logo',
    dataType: 'json',
    data: { "isCreateThumbnail": "true", "Width": 55, "Height": 60, "Mode": "W" },
    success: function (data, status) {
    if (data.error == "true") {
    AlertInfo('操作提示', '上传失败,请重新上传');
    return false;
    }
    $("#hfLogo").val(data.path);
    $("#imgLogo").attr("src", data.path);
    },
    error: function (data, status, e) {
    AlertInfo('操作提示', '上传失败,请重新上传');
    return false;
    },
    });
    });

    #region 上传图片
    /// <summary>
    /// 上传图片
    /// </summary>
    /// <returns></returns>
    public void UpLoadImage(HttpContext hc)
    {
    bool isCreateThumbnail = GetRequest("isCreateThumbnail", false);
    int Width = GetRequest("Width", 55);
    int Height = GetRequest("Height", 60);
    string Mode = GetRequest("Mode", "W");
    //是否返回图片的宽高,默认是不返回
    bool isReturnBigWidthHeight = GetRequest("isReturnBigWidthHeight", false);

    hc.Response.ContentType = "text/html";
    string result = "{error:'true'}";
    try
    {
    HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
    if (files == null && files.Count < 1)
    {
    hc.Response.Write(result);
    return;
    }
    PicUploadResult picResult = UploadFile.UpLoadImage(files[0], isCreateThumbnail, Width, Height, Mode, isReturnBigWidthHeight);
    picResult.BigPicturePath = picPathPrefix + picResult.BigPicturePath;
    picResult.SmallPicturePath = picPathPrefix + picResult.SmallPicturePath;

    hc.Response.Write("{error:'false',path:'" + picResult.BigPicturePath + "',smallPicPath:'" + picResult.SmallPicturePath + "',picWidht:'" + picResult.BigPicWidth + "',picHeight:'" + picResult.BigPicHeight + "'}");
    }
    catch (Exception ex)
    {
    hc.Response.Write(result);
    }
    }
    #endregion

  • 相关阅读:
    求逆序对的解法
    关于宽搜BFS广度优先搜索的那点事
    大数乘法 poj2389
    二分求幂(快速求幂,二进制求幂)
    2n皇后问题
    poj2406 Power Strings (kmp 求最小循环字串)
    poj1050查找最大子矩阵和
    二叉树的建立和遍历
    已知二叉树前序和中序,求二叉树。
    c/c++连接mysql数据库设置及乱码问题(vs2013连接mysql数据库,使用Mysql API操作数据库)
  • 原文地址:https://www.cnblogs.com/ztf20/p/9886106.html
Copyright © 2011-2022 走看看