多文件上传器扩展检查不能一直工作 [英] Multi file uploader extension checking not working all the times
本文介绍了多文件上传器扩展检查不能一直工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的代码,在我选择的特定多文件上传器的文件中检查-b.doc我的问题是支持如果我选择
200-c.docx,201-C.docx, 202.wma和203.wma有相同的命令它说有效格式它有效并且有时不工作。
我尝试了什么:
i尝试上面的代码,但是当我多次执行时它不起作用
Below is my code which checks for -b.doc in my selected files of that particular multiple fileuploader my problem is suppos if i choose
200-c.docx,201-C.docx,202.wma and 203.wma with same order it is saying validformat it is working some times and not working some times.
What I have tried:
i tried above code but it is not working when i do it multiple times
推荐答案
应该尝试:
Should tried:
if (myfile.indexOf("-c.doc") != -1 || myfile.indexOf("-C.DOC") > != -1)
您可以使用小写和大写来测试文件名,但任何混合都会失败。
您需要转换测试前将文件名设置为小写或大写。
You test the filename against lowercase and against uppercase, but any mix will fail.
You need to convert the filename to lowercase or uppercase before testing.
var myfile = chkFile.value.ToLower();
var validExtension = "-c.doc";
label.innerText = myfile.EndsWith(validExtension) ? "Valid Format" : "Invalid Format";
更新:这是检查以上代码是否有效的测试:
C#6 +版本
UPDATE: Here is a test to check that the above code works:
C#6+ version
var files = new List<string> { "aaa.mp3", "aaa-c.mp3", "aAa-c.DoC", "aAa-c.doc" };
var validExtension = "-c.doc";
foreach (var file in files)
{
Console.WriteLine(
这篇关于多文件上传器扩展检查不能一直工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文