上传图片2

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

 

<td>
<!--照片上传功能在此处-->
<input type="file" id="ConfirmFileUpload_Logo" name="ConfirmFileUpload_Logo" style="width: 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

 

posted @   Best丶zhaotf  阅读(165)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
点击右上角即可分享
微信分享提示