日期:2014-05-16 浏览次数:20401 次
function PostImage() {
$.post("../../../AjaxResponse/Handler.ashx?time=" + Math.random(), {
imgPath: $("#imgFileUpload").val(),
action: "checkSize",
filepath: "temp",
maxSize: "5000"
},
function (data) {
$("#imgPreview").attr("src", data.toString()); //显示缩略图
});
}
public class TypeEditCoverHandler : IHttpHandler
{
//获取栏目类别的封面图片
public void ProcessRequest(HttpContext context)
{
//context.Request.ContentType = "multipart/form-data";
context.Response.ContentType = "text/plain";
//获取页面传过来的状态
string strState = context.Request["action"];
//获取文件大小限制
int maxSize = Moore.Help.DataConverter.StrToInt(context.Request["maxSize"]);
//获取文件路径
string strImgPath = context.Request["imgPath"]; //能正确读到:D:\图片上传测试\04.jpg
HttpPostedFile imgPostFile = context.Request.Files[strImgPath]; //一直为null
//临时文件名称
string strTempImageName = String.Empty;
…… 后面的略