I store some files in my database, and since I store them in binary format and do not store any other information, I have to make sure that they are all in the same format so that I can "service" them later (if there is an easy way to output file type from an array of bytes, tell me, but this is not the focus here).
So what I need to do is check each downloaded file to make sure it is in the right format.
I installed FieldTemplate with the FileUpload control and CustomValidator:
<asp:FileUpload ID="FileUpload" runat="server" />
<asp:CustomValidator
ID="CustomValidator1"
runat="server"
ErrorMessage="PDF only."
ControlToValidate="FileUpload"
OnServerValidate="CustomValidator1_ServerValidate">
</asp:CustomValidator>
What I am missing is the code that should be placed in this CustomValidator1_ServerValidate method, which checks the downloaded file to make sure it is in the right format (in this case, PDF).
.