• 上传图片


    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);
    }

  • 相关阅读:
    JAVA反射机制--静态加载与动态加载
    MyEclipse导入Hibernate出现Path must include project and resource;/project name
    服务器和java程序的桥梁--jdbc/hibernate
    AndroidStudio快捷键大全
    AndroidStudio怎么实现微信分享功能
    《一面》
    java泛型
    java设计模式-Observer(2)
    java设计模式-Observe
    HashSet的自定义实现
  • 原文地址:https://www.cnblogs.com/q101301/p/3939487.html
Copyright © 2020-2023  润新知