国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > 綜合 > 正文

C#編寫(xiě)的生成縮略圖程序

2024-07-21 02:17:41
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友


收集最實(shí)用的網(wǎng)頁(yè)特效代碼!

 

if(fileupload.postedfile!=null)
     {    
      //addto為要添加的屬性,aboutfile為文件說(shuō)明
      string nam = fileupload.postedfile.filename ;
      //取得文件名(抱括路徑)里最后一個(gè)"."的索引
      int i= nam.lastindexof(".");
      //取得文件擴(kuò)展名
      string newext =nam.substring(i);
      //這里我自動(dòng)根據(jù)日期和文件大小不同為文件命名,確保文件名不重復(fù)
      datetime now = datetime.now;
      string newname=now.dayofyear.tostring()+fileupload.postedfile.contentlength.tostring();
      //保存文件到你所要的目錄,這里是iis根目錄下的upload目錄.你可以改變.
      //注意: 我這里用server.mappath()取當(dāng)前文件的相對(duì)目錄.在asp.net里"/"必須用"http://"代替,把"upload//"改成"http://upload//"就成了取當(dāng)前文件的絕對(duì)目錄了
      fileupload.postedfile.saveas(server.mappath("upload//"+newname+newext));
      //得到這個(gè)文件的相關(guān)屬性:文件名,文件類型,文件大小
      //fname.text=myfile.postedfile.filename;
      //fenc.text=myfile.postedfile.contenttype ;
      //fsize.text=myfile.postedfile.contentlength.tostring();
      //下面是生成縮略圖
      system.drawing.image image,anewimage;
      int width,height,newwidth,newheight;      
      image=system.drawing.image.fromfile(server.mappath("upload/"+newname.tostring()+newext.tostring()));
      system.drawing.image.getthumbnailimageabort callb =new system.drawing.image.getthumbnailimageabort(thumbnailcallback);    
      width=image.width;
      height=image.height;
      if(firstpageshow.selectedvalue.tostring()=="1"&&fenlei.selectedvalue.tostring()=="5")
      {
       newwidth=203;newheight=86;       
       newheight=height*newwidth/width;
      }
      else if(isweekman.selectedvalue.tostring()=="1")
      {
       newwidth=171;newheight=111;
       newheight=height*newwidth/width;
      }
      else if(firstpageshow.selectedvalue.tostring()=="1"&&fenlei.selectedvalue.tostring()=="3")
      {
       newwidth=171;newheight=111;
       newheight=height*newwidth/width;
      }
      else
      {
       newwidth=62;newheight=80;
       newheight=height*newwidth/width;
      }
      anewimage=image.getthumbnailimage(newwidth,newheight,callb,new system.intptr());
      anewimage.save(server.mappath("upload//"+"small_"+newname+newext));
      image.dispose();
      //生成縮略圖 生成并保存完畢,保存名是在原圖名前加了一個(gè)small_。
      pic="upload/"+newname.tostring()+newext.tostring();
      smallpic="upload/small_"+newname.tostring()+newext.tostring();
     }


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 湖州市| 赣榆县| 密云县| 兴仁县| 莎车县| 资溪县| 莫力| 安平县| 公主岭市| 略阳县| 米脂县| 德保县| 衡南县| 濮阳市| 永康市| 游戏| 眉山市| 钟山县| 宁安市| 达孜县| 满洲里市| 高雄市| 武义县| 肥城市| 韩城市| 江陵县| 石台县| 临沭县| 保德县| 板桥市| 保山市| 化州市| 吉隆县| 内黄县| 青岛市| 台湾省| 滁州市| 渝北区| 舒城县| 庆安县| 苗栗县|