asp.net - 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);
}
}
解决方案
推荐阅读
- c++ - UE4 - 如何在给定 4 个屏幕坐标的情况下缩放纹理或材质?
- spring-integration - Spring 集成 Java DSL 示例
- swift - 如何将变量声明为 Equatable?
- typescript - 如何根据传递的类判断构造函数的类型?
- python - “需要一个类似字节的对象,而不是 str”Python 中的错误
- python - Python 3 中的内部类中的超级
- swift - 如何快速在属性包装器结构中实现属性观察器?
- java - 如果发生内存突变,有关在 Java 中展开的问题
- python-3.x - 对于 wx.Python,style=wx.NO_BORDER 如何让包含在其中的类看不到宽度或高度
- c# - C# 更改 Windows 的“特殊文件夹”