上传文件

        protected void btnUpload_Click(object sender, EventArgs e)
        {
            HttpFileCollection Files = HttpContext.Current.Request.Files;
            for (int i = 0; i < Files.Count; i++)
            {
                HttpPostedFile PostedFile = Files[i];
                if (PostedFile.ContentLength > 0)
                {
                    string FileName = PostedFile.FileName;
                    string strExPrentFile = FileName.Substring(FileName.LastIndexOf(".") + 1);

                    string sFilePath = "/uploadfile/hotel/" + StringClass.makeFileName24() + i + strExPrentFile;
                    PostedFile.SaveAs(Server.MapPath(sFilePath));
                }
                else
                {
                    //this.LabMessage.Text = "不能上传空文件";
                }
            }
        }
本博客有部分内容来自网络,如有问题请联系:hebeilijianghua@qq.com,并注明来自博客园。
原文地址:https://www.cnblogs.com/leebokeyuan/p/6062409.html