Quantcast
Channel: AjaxFileUpload Control hasFile Validation
Viewing all articles
Browse latest Browse all 14

Re: AjaxFileUpload Control hasFile Validation

$
0
0

Nan

 can you help me in one more thing , I am using the following code to check the valid .df file , it is executing but not able to alert to the user that it is not a valid pdf file 

and AjaxFileUpload control is showing "File Uploaded" which is wrong 

how to handle it , can you please help in it 

 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
end sub


Viewing all articles
Browse latest Browse all 14

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>