上传图片
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);
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 现代计算机视觉入门之:什么是图片特征编码
· .NET 9 new features-C#13新的锁类型和语义
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· Spring AI + Ollama 实现 deepseek-r1 的API服务和调用
· 《HelloGitHub》第 106 期
· 数据库服务器 SQL Server 版本升级公告
· C#/.NET/.NET Core技术前沿周刊 | 第 23 期(2025年1.20-1.26)