日期:2014-05-17 浏览次数:20482 次
public class up_img : IHttpHandler
{
double deLength = 2048;//默认大小
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
System.Web.HttpPostedFile postFile = context.Request.Files[0];
if (postFile != null)
{
if (IsAllowedExtension(postFile) == false)
{
context.Response.Write("error:-5");//上传文件类型错误!
return;
}
if (postFile.ContentLength <= 0 || postFile.ContentLength / 1024 > deLength)
{
//context.Response.Write((postFile.ContentLength / 1024).ToString());
context.Response.Write("error:-4");//Slip:上传文件大小错误!
return;
}
try
{
Image drimg = Image.FromStream(postFile.InputStream);
int Height = drimg.Height;
int Width = drimg.Width;
byte[] bytes = PhotoManager.ConvertImage(drimg);
drimg.Dispose();
if (Height >= 300 && Width >= 300)
&nbs