首页 > 解决方案 > Fileupload 控件在实时环境中上传额外的文件

问题描述

我知道这是文件上传控制的一种非常奇怪的行为,但我需要了解它。在实时环境中,当我在上传控件中选择两个文件时,它会上传并显示 7 个文件(2 个原始文件 + 5 个额外文件)。我不知道这 5 个额外的文件是从哪里来的。在本地它工作得很好。请建议我必须在这里检查的内容。我也在使用 js 来上传多个文件。

下面是我的代码:

string newPath = string.Empty;
            
            if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
            {
                //var count = 0;

                string strMainFolderPath = Server.MapPath("~/UploadFiles/CR/");

                //Create a new subfolder in the main folder.
                newPath = System.IO.Path.Combine(strMainFolderPath, crid.ToString());

                DirectoryInfo objDirectory = new DirectoryInfo(newPath);

                if (!objDirectory.Exists)
                {
                    System.IO.Directory.CreateDirectory(newPath);
                }

                foreach (HttpPostedFile uploadedFile in File1.PostedFiles)
                {
                   
                    string fileName = Path.GetFileName(uploadedFile.FileName);
                   
                    uploadedFile.SaveAs(newPath + "\\" + fileName);                            
                                       
                }
                
            }

标签: asp.netfile-upload

解决方案


推荐阅读