SWFUpload后台取数据
HttpPostedFileBase file = Request.Files["Filedata"];//接收客户端传递过来的数据.
string fileName = Path.GetFileName(file.FileName);//获取文件名称.
string fileExt = Path.GetExtension(fileName);//获取扩展名称.
if (fileExt == ".jpg")
{
//file.SaveAs(Request.MapPath("/UploadImage/"+fileName));
string dir = "/UploadImage/"+DateTime.Now.Year+"/"+DateTime.Now.Month+"/"+DateTime.Now.Day+"/";
Directory.CreateDirectory(Path.GetDirectoryName(Request.MapPath(dir)));//创建目录
string fullDir = dir +Common.WebCommon.GetStreamMD5(file.InputStream)+ fileExt;//构建完整路径.
//图片的压缩(缩略图.)
file.SaveAs(Request.MapPath(fullDir));
string thumbUrl = "/UploadImage/" + Guid.NewGuid().ToString() + ".jpg";
int height;
Common.ImageClass.MakeThumbnail(Request.MapPath(fullDir), Request.MapPath(thumbUrl), 200, 300, "W",out height);
// using (Image img = Image.FromStream(file.InputStream))//根据原始图创建一个Image,Image的高度与宽度就是上传图片的高度与宽度.
return Content("ok:" + thumbUrl+":"+height);
}
return Content("no:格式错误!!");