Showing posts with label File Uploader control. Show all posts
Showing posts with label File Uploader control. Show all posts

Wednesday, January 5, 2011

Check for File Uploading using vb.net

Hi,

Public Function chk_FileExtension(ByVal str As String) As Boolean
Dim extension As String = str
Dim MIMEType As String = Nothing
Select Case extension
Case ".jpeg"
Return True
Case ".jpg"
Return True
Case ".gif"
Return True
Case ".png"
Return True
Case ".bmp"
Return True
'Case ".pdf"
' Return True
Case Else
Return False
'return;
Exit Select
End Select
End Function

-----------------------------------------------------------
If flpSwatchImage.FileName = Nothing Then
Call objFunction.setMessage("INFO", "Please Provide any Image.", False)
Exit Sub
Else
If chk_FileExtension(Path.GetExtension(flpSwatchImage.FileName).ToLower()) = True Then
objColors.colorSwatch = flpSwatchImage.FileName
Else
Call objFunction.setMessage("INFO", "The Extension of the file Provided is not Allowed.", False)
Exit Sub
End If
End If