Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Type Validation - Client Side?

Status
Not open for further replies.

DallasAggie

Programmer
Oct 24, 2002
98
US
Hey all!

I have a simple upload utility that will post files to our web server --- from there, the file then gets uploaded into Crystal Enterprise.

Since we only want to post .rpt files (Crystal Reports), I had code to validate the file
Code:
string fileType = cr_File_reportBrowse.PostedFile.ContentType.ToString();

if (fileType != "application/x-rpt")
   {
       cr_File_reportBrowse.Dispose();
       cr_lbl_Messages.Text = "You must select a file of type Crystal Reports. You attempted to upload a file of type " + fileType;

   }

This seemed to work fine on my development machine, but when I tried it remotely (from a machine that doesn't have .rpt files registered), it would read .rpt files as "application/octet-stream" ... thus causing it to fail.

My question is: Is there a different way to validate the file type? I tried using Regular Expression Validator with this expression:
Code:
^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.rpt|.RPT)$

...as suggested by Microsoft: ... but that doesn't seem to help. Actually, it doesn't even throw an error ... Maybe the expression is wrong?

Any..and ALL suggestion/advice is welcomed :)

Thanks,
DallasAggie
 
I'm an idiot!!! The Regular Expression Validator is working fine now --- I was trying it on a remote server without compiling !!! D'oh! Sorry all!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top