Dear Friends
I need to validate the pdf file , for is it a actual pdf file or not ?
I am using this code on AjaxFileUpload onUploadComplete event like this
Protected Sub AjaxFileUpload1_OnUploadComplete(ByVal sender As Object, ByVal file As AjaxFileUploadEventArgs) Handles AjaxFileUpload1.UploadComplete
' User can save file to File System, database or in session state
' Validation added to check the taken file is a real pdf file or not
Dim r As New System.IO.BinaryReader(file.GetStreamContents)
Dim fileclass As String = String.Empty
Dim buffer As Byte
buffer = r.ReadByte()
fileclass = buffer.ToString
buffer = r.ReadByte
fileclass &= buffer.ToString
If (fileclass = "3780") Then
bool1 = True
Else
bool1 = False
End If
If bool1 = False Then
Label1.Text = "please Choose a Valid pdf File"
Exit Sub
End If
If Not r Is Nothing Then
r.Dispose()
End If
the problem is , the code is running but I need to alert to user for valid pdf file but the label is not showing although it is oging in that block
and the Control is showing fileuploaded successfully even the file is not uploaded
how to handle it please help