• 上传图片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

  • 相关阅读:
    (原)在ubuntu 中安装 swi prolog 和 简单的使用
    (转) 新手入门:C/C++中的结构体
    (转) eclipse debug (调试) 学习心得
    flutter: 根视图、根元素与根渲染
    eggjs的参数校验模块egg-validate的使用和进一步定制化升级
    Vue源码中用到的工具函数
    21 项优化 React App 性能的技术
    react-redux 的使用
    编写 Vue.js 组件前需要知道的 10 件事
    Flutter实现抽屉动画效果
  • 原文地址:https://www.cnblogs.com/ztf20/p/9886106.html
Copyright © 2020-2023  润新知