asp.net c#版上传各种文件源代码示例中篇

Admin | 2008-5-20 18:22:31 | TrackRecord: 1530 Times | Tag标签:asp.net 打印本页

您当前所处的位置是:〖首页〗→【文章页】 本站共有16个图文教程栏目,请用心拜读!

本站提供经典的Excel公式函数实例,Word排版技巧,PPT教程;同时更兼有Flash,PowerPoint,数据库等技术文章。

//加图片水印
    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>



上一篇:asp.net c#版上传各种文件源代码示例    下一篇:asp.net c#版上传各种文件源代码示例

会员评论列表:
针对本篇文章或本站,请您发表个人的建议或批评!
FreeBoxPc

谷歌搜索 百度搜索 本站仅与内容具备一定的实用价值的原创网站交换友情链接,力争为大众做出更优质的服务!
All Rights Reserved版权所有 本站备案信息:滇ICP备11001339号-2 站长联系方式 Email:dzwebs@126.com