File Upload - ValidationExpression (ASP.NET). Please help!!!

B

bienwell

Hi all,

I have a web pagedeveloped in ASP.NET (VB program). On my web page, I have a
FILE object
<input id="File1" type="file" size="70" name="File1" runat="Server" />

I declared

<asp:regularexpressionvalidator id="RegularExpressionValidator1"
runat="server" ForeColor="LightCoral"
ValidationExpression="^([a-zA-Z]:(\\(\w[\w].*))*\\((\w{2}|\w{3})(M|m)(K|k)(T|t)\d{4}_\d{2}_\d{2}(.csv|.CSV|.Csv|.txt|.Txt|.TXT)))$"

ErrorMessage="You must specify the file location and the filename
must follow this convention: CC(C)_Mktyyyy_mm_dd.csv"
ControlToValidate="File1"></asp:regularexpressionvalidator>

The file to upload will look like AB_MKT2009_02_28.csv OR
ABC_MKT2009_02_28.csv

If the users save the file in local machine, they can type in
C:\folder1\folder2\...\AB_MKT2009_02_28.csv in the file textbox OR click
Browse button to locate the file. There was no problem in this case.

Here are some problems:

1) Some users use MACHINTOST and run my application. When they select
Browse button to locate the file, it displays something on the textbox:
/users/folder1/folder2/..../AB_MKT2009_02_28.csv

There were some slashes in each subfolder and they don't match with the
things I put in the validationExpression . Users received the errror message
"You must specify the file location and the filename must follow this
convention: CC(C)_Mktyyyy_mm_dd.csv" from my rule.

2) Some users put the files in network drive. When they select Browse
button to locate the file, it displays something on the textbox:
\\HpFolder\users\...\Mydocument\...\AB_MKT2009_02_28.csv

There's no drive name in the textbox. They got the error message : "You must
specify the file location and the filename must follow this convention:
CC(C)_Mktyyyy_mm_dd.csv" from my rule.

I have some questions:
1) If I don't specify the drive name [a-zA-Z]: in the validation
expression, can my web page recognize the path and the filename? (such as
\folder1\folder2\...\AB_MKT2009_02_28.csv). How do I handle the "/" and "\"
.. Do I need to put it in ValidationExpression?
2) How can ASP.NET page handle problem 1 and 2 I mentionned above?
3) Do I need to change the validation expression to handle all the
cases? Please help me in this case.

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top