//加图片水印 System.Drawing.Image image=System.Drawing.Image.FromFile(fromFullPath); string fixinfo=image.PixelFormat.ToString(); if(fixinfo=="Format1bppIndexed"||fixinfo=="Format4bppIndexed"||fixinfo=="Format8bppIndexed"||fixinfo=="Undefined"||fixinfo=="DontCare"||fixinfo=="Format16bppArgb1555"||fixinfo=="Format16bppGrayScale") { WebFile.PostedFile.SaveAs(FullPath); } else { System.Drawing.Image copyImage=System.Drawing.Image.FromFile(UploadNewsPath + @"\"+"AlaOne.gif"); Graphics g=Graphics.FromImage(image); g.DrawImage(copyImage,new Rectangle(image.Width-copyImage.Width,image.Height-copyImage.Height,copyImage.Width,copyImage.Height),0,0,copyImage.Width,copyImage.Height,GraphicsUnit.Pixel); g.Dispose();
//保存加水印过后的图片,删除原始图片 //string newPath=Server.MapPath(".")+"/img/"+fileName+"_new"+extension; image.Save(FullPath); image.Dispose(); if(File.Exists(fromFullPath)) { File.Delete(fromFullPath); } } }
/// <summary> /// 上传新闻视屏 /// </summary> /// <param name="WebFile"></param> /// <param name="strFileName"></param> public void UploadVideoFile(System.Web.UI.HtmlControls.HtmlInputFile WebFile,string strFileName) { char[] spliter = {'\\'}; string [] FileName = strFileName.Split(spliter,10); string FullPath = UploadVideoPath + @"\" + @"\" + FileName[FileName.Length-1]; //生成完整文件名 WebFile.PostedFile.SaveAs(FullPath); //保存文件 }
/// <summary> /// 上传Flash文件 /// </summary> /// <param name="WebFile"></param> /// <param name="strFileName"></param> public void UploadFlashFile(System.Web.UI.HtmlControls.HtmlInputFile WebFile,string strFileName) { char[] spliter = {'\\'}; string [] FileName = strFileName.Split(spliter,10); string FullPath = UploadSwfPath + @"\" + @"\" + FileName[FileName.Length-1]; //生成完整文件名 WebFile.PostedFile.SaveAs(FullPath); //保存文件 } /// <summary>
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18