Cannot get MulitiFile upload and Validation to work

Dec 17, 2013 at 7:55 PM
Cannot get MulitiFile upload and Validation to work

I am looking for a validation expression sample when using multi-file upload.

I simply dropped onto a blank web form a multi upload control. This WORKS JUST fine. If I add a validation control (RegularExpressionValidator) to the screen then all uploads are prevented (due to validation fail).

I using this expression for the validate:


The above works fine if I place a regular text box on the form and cut+paste in the file name to this regular text box. Not 100% sure, but I believe multi-file upload passes the whole path name string to validation?

So above does allow ":" and "\" so thus c:\somefilename.pdf ALSO passes validation of a standard text box. So we do have a working validation here.

Is just each single file name passed to validation?
Or is ALL FILE names passed as a SINGLE STRING separated by some delimiter to the validation expression?

Does anyone have a suggested validation expression that will work?
I am open to the idea of adding some jscript code to validate the file(s) selected if this is possible when using the multiple file upload.

I am NOT use the flash option to allow multiple files to be selected on one try but validation FAILS EVEN when only selecting one file anyway.

As noted the multiple file upload control works 100% fine and ALLOWS multiple file upload. Adding the progress bar to the form ALSO WORKS just fine.

The instant I add a validation control to the form then I am unable to validate using the above or in fact ANY expression except those that allow every possible string.

Using Vs2010 +

I am thrilled and much grateful for those here who shared this code. And it rather amazing how well this upload library works.

Unfortunately this validation issue is now costing me far more time than expected and as an result is creating a very bad experience for me.

Again, grateful to anyone who has a suggestions or pointing me in a another direction that will yield fruit.

Best regards
Albert D. Kallal (Microsoft MVP)
Edmonton, Alberta Canada
Dec 18, 2013 at 10:13 AM
Ok, as a follow up the validation string for the MultiFile control does seem to be separated by a ";". This is clearly outlined in the help document.

The result of course is that a typical regex expression used to validate single file name will not work since there are EXTRA characters after the file name

So even a single file selected, the validation gets this:


Note the trailing ";" here.

And if there are two files, then you get


It is rather tricky to get a reg expression that works on groups – but it is possible.

I also find that dropping in a custom valuation control also correctly gets called (well done folks!!).

However, I cannot work out how to get in jscript to grab any information about the control:

I am thinking this should work:


If ANYONE has how to ref the control with jscript then most appricate.

I hope this post helps others realize that validation with multi-file means one has to create a regex expression has to handle multiple files separated by a ";"

Once I get a regex expression that works then I will come back and follow up.

Thanks again.

Best regards,
Albert D. Kallal
Edmonton, Alberta Canada
Dec 19, 2013 at 2:07 AM
More follow up:

For SOME resason using getElementbyID is now working fine. As per above post this works:
    function GetInputFile1() {

        var FU = document.getElementById("InputFile1");


    function GetMultiFile1()

        var FU = document.getElementById("MultiFile1");

So above lets one get/grab and reference what file name is selected before a post back.

In the case of a multi-file, then as noted the string is multiple files each separated by a ";" and even in the case of one file the ending ";" is included.

I have no idea why the above code was not working before (lost a whole day). I am however now able to get the element from the web page DOM with ease now.

I suppose next up would be some examples to calling the neat upload "js" library functions by passing this reference. I do plan to modify the look + feel of the multiple selected files into some nice looking grid and change the "x" to a buttom.

Once again, I hope my follow up helps any readers here.

Best regards,
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada