Reputation: 115
I need to create a regular expression in a FileUpload, that only allow pdf files
<asp:RegularExpressionValidator runat="server" ID="valUpTest" ControlToValidate="FileUpload1"
ErrorMessage="Files Only (.pdf)" ValidationExpression="?" />
Upvotes: 0
Views: 1781
Reputation: 5004
You cant trust client side validation alone nor file extension. You need to open the uploaded binary data and check if the headers of the file is "correct".
Upvotes: 1
Reputation: 2344
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx
There is an example about 3/4 of the way down the page how to do this the ASP way.
Upvotes: 1