form提交上传图片

html:

       

<!--<form method="post" action="../ashx/Management.ashx" enctype="multipart/form-data" target="myiframe">

<input id="file1" name="file1" type="file" />
<input id="upload" type="submit" value="上传" /></form>
<iframe width="505" height="500" name="myiframe" id="myiframe" frameborder="0" scrolling="no"></iframe>-->

 

 

一般处理程序(ashx):

 

//HttpPostedFile fileUpload2 = context.Request.Files["file1"]; // 接收图片

//string filename = fileUpload2.FileName; // 图片name
//string serverpath = System.Web.HttpContext.Current.Server.MapPath("../imglist/" + filename); // 保存路径
//fileUpload2.SaveAs(serverpath); // 保存

//System.Drawing.Image img = System.Drawing.Image.FromFile(serverpath);

//System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(serverpath);
//bitmap.Save("c:\\button.Png", System.Drawing.Imaging.ImageFormat.Png);// 格式转换

// fileUpload2.SaveAs(serverpath);

posted @ 2013-10-16 16:35  幸福就好  阅读(632)  评论(0编辑  收藏  举报