乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      asp.net中文件如何上傳到服務(wù)器上

       修行的嘟嘟 2010-06-01
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Web;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      using System.IO;
      namespace SuAn
      {
          public partial class WebForm1 : System.Web.UI.Page
          {
              protected void Page_Load(object sender, EventArgs e)
              {
              }
              protected void Button1_Click(object sender, EventArgs e)
              {
                  if (this.filepost.PostedFile.FileName == "")
                  {
                      Response.Write("上傳文件不能為空!");
                      return;
                  }
                  try
                  {
                      string  Path = Server.MapPath("upload/");//設(shè)置服務(wù)器端路徑
                      string filePath = this.filepost.PostedFile.FileName;//獲取客戶端實際路徑
                      string fileName = filePath.Substring(filePath.LastIndexOf("\\")+1);//獲取文件名稱
                      string serverPath = Path + fileName;//上傳的文件保存到服務(wù)器端的路徑
                      System.Text.StringBuilder buider = new System.Text.StringBuilder();//上傳的文件信息:可變字符串
                      buider.Append("上傳文件的類型:"+this.filepost.PostedFile.ContentType.ToString()+"");
                      buider.Append("客戶端文件地址:"+this.filepost.PostedFile.FileName+"");
                      buider.Append("上傳文件名稱:"+fileName);
                      buider.Append("上傳文件的擴展名:"+filePath.Substring(fileName.LastIndexOf(".")+1));
                      buider.Append("上傳文件的大小:"+this.filepost.PostedFile.ContentLength/1024+"k"+"");
                      if (System.IO.File.Exists(serverPath))
                      {
                          Response.Write("這個文件在服務(wù)器上已經(jīng)存在,請不要重復(fù)上傳!");
                          return;
                      }
                      string str = fileName.Substring(fileName.LastIndexOf(".")+1);//獲取文件后綴名
                      if (str == "jpg" || str == "rar" || str == "ppt")
                      {
                          Response.Write("對不起,該類型文件不能被上傳!");
                          return;
                      }
                      if (this.filepost.PostedFile.ContentLength >2048)
                      {
                          Response.Write("對不起,文件不能超過2K");
                          return;
                      }
                      this.filepost.PostedFile.SaveAs(serverPath);//上傳保存文件
                      this.lblMessage.Text = buider.ToString();
                  }
                  catch(Exception ex)
                  {
                      Response.Write(ex.Message);
                  }
                 
              }
          }
      }

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多