码迷,mamicode.com
首页 > Web开发 > 详细

上传文件(文件另存为,有指定的路径)

时间:2016-04-18 18:52:25      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:

private SellerInfo uploadFile()     {         SellerInfo sellerInfo = new SellerInfo();

        String filePath = Server.MapPath("~/" + SellerReservatBL.SELLER_INFO_FILE);

        sellerInfo.ID = Request.QueryString["ID"];         sellerInfo.Sup_No = this.Sup_No.Text;         sellerInfo.Site_No = this.DlistStore.Text;         sellerInfo.EntryDate = this.ReservationDate.Text;         sellerInfo.SellerName = this.SellerName.Text;         sellerInfo.CardId = this.CardId.Text;         sellerInfo.Phone = this.Phone.Text;         sellerInfo.Brand = this.Brand.Text;         sellerInfo.OnlinePurchase = this.OnlinePurchase.Text;         sellerInfo.BussinessName = this.BussinessName.Text;         sellerInfo.BussinessPhone = this.BussinessPhone.Text;

        if (string.IsNullOrEmpty(this.FileUrl.Text))         {             if (!Directory.Exists(filePath + "/" + GetLoginUserNo()))             {                 Directory.CreateDirectory(filePath + "/" + GetLoginUserNo());             }

            if (string.IsNullOrEmpty(sellerInfo.ID))             {                 sellerInfo.ID = sellerBL.GetNextID("SellerInfo", "ID");             }

            HttpFileCollection hfc = Request.Files;             for (int i = 0; i < hfc.Count; i++)             {                 HttpPostedFile hpf = hfc[i];                 if (hpf.ContentLength > 0)                 {                     sellerInfo.AdjunctURL = filePath + "/" + GetLoginUserNo() + "/" + sellerInfo.Sup_No + "_" + sellerInfo.Site_No + "_" + sellerInfo.ID + ".rar";                 }             }

            for (int i = 0; i < hfc.Count; i++)             {                 HttpPostedFile hpf = hfc[i];                 if (hpf.ContentLength > 0)                 {                     hpf.SaveAs(sellerInfo.AdjunctURL);                 }             }         }         else         {             sellerInfo.AdjunctURL = this.FileUrl.Text;         }

        return sellerInfo;     }

上传文件(文件另存为,有指定的路径)

标签:

原文地址:http://www.cnblogs.com/Carri/p/5405144.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!