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

    function UpLoadImage()
    {
    $('#UploadForm').attr("action", "/sation/handlers/UploadImage.ashx");
    $('#divBillboardImage').parent().appendTo($('#UploadForm'));
    $("#UploadForm").ajaxSubmit({
    url: "/sation/handlers/UploadImage.ashx",
    type: "post",
    dataType: "json",
    success: function(data)
    {
    if (data.resault == "ok") {
    $("#U14").append("<li><div><img width='120px' url='"+data .SavePath+"' class='image1' height='120px' src='" + data.ServerPath + "'/><br/><a href='javascript:void(0)' onclick='DelImage(this,1)' >删除</a></div></li>");
    }
    else if (data.resault == "error") {
    alert(data.msg);
    };
    },
    error:function ()
    {
    alert ("异常");
    }
    });

    }
    function DelImage(obj,index)
    {
    var li=obj .parentNode.parentNode;
    li .remove();
    var images="";
    $(".image"+index).each(function (){
    images +=$(this ).attr("url")+"|";
    })
    alert (images);
    alert ($(".image"+index).length);
    $("#<%=HiddenImages.ClientID %>").val(Images);
    $.ajax({
    type: "get",
    url: "/sation/handlers/ServicesItem/UpdateImage.ashx",
    data:{"Images":Images,"id":<%=ServiceItemID%>},
    success: function(msg) {
    if (msg == "ok") {
    alert("删除成功");
    // window.location.href=location .href ;
    } else {
    alert("删除成功");
    }
    },
    error: function(msg) {
    alert("请求异常");
    }
    });
    }
    }

    context.Response.ContentType = "text/plain";
    HttpPostedFile File = context.Request.Files["tempImage"];
    if (File != null)
    {
    FileSettingEntity fileVaild = FileManger.GetFileSetting((int)ESourceType.fromStationImg);
    if (File.ContentLength > fileVaild.Length)
    {
    context.Response.Write("{"resault":"error","msg":"" + "上传的图片大小不能超过" + fileVaild.Length / 1024 + "kb!" + ""}");
    return;
    }
    FileEntity fentity = null;
    try
    {
    fentity = Gasgoo.B2C.Common.FileUpload.ReceptionUploadFixedGIPImage(File, ESourceType.fromStationImg, 0, UserId, false);
    }
    catch
    {
    context.Response.Write("{"resault":"error","msg":"请上传.jpeg|.jpg|.gif格式文件!"}");
    return;
    }
    string Path = FileFactory.GetFilePathByFileArray(fentity.SavePath, ESourceType.fromStationImg);
    string ImgFile = string.Empty;
    ImgFile = "{"resault":"ok",";
    ImgFile += ""msg":"",";
    ImgFile += ""SavePath":"" + fentity.SavePath + "",";
    ImgFile += ""ServerPath":"" + Path + """;
    ImgFile += "}";
    context.Response.Write(ImgFile);
    }

  • 相关阅读:
    UML各种图总结
    信息系统安全等级保护基本要求
    MySQL InnoDB表空间加密
    服务器常见操作问题
    公众号-接口配置信息 接口实现 netcore
    某些时候命令绑定可能会存在刷新不及时,往往需要点击一次程序才能激活,特此记录下解决方案
    c#几种场景获取程序运行目录
    wpf 控件绑定鼠标命令、键盘命令
    并发特别高的时候,随机数的种子生成
    mongodb占用大量内存
  • 原文地址:https://www.cnblogs.com/q101301/p/3939487.html
Copyright © 2011-2022 走看看