Torna al Thread

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim intFileSizeLimit As Integer = 10 Dim strFileNameWithPath As String = FileUpload1.PostedFile.FileName Dim strExtensionName As String = System.IO.Path.GetExtension(strFileNameWithPath) Dim strFileName As String = System.IO.Path.GetFileName(strFileNameWithPath) Dim intFileSize As Integer = FileUpload1.PostedFile.ContentLength / 1024 strExtensionName = strExtensionName.ToLower() If strExtensionName.Equals(".jpg") OrElse strExtensionName.Equals(".gif") Then If intFileSize < intFileSizeLimit Then Dim bmp As New Bitmap(FileUpload1.PostedFile.InputStream) If bmp.Height < 100 And bmp.Width < 100 Then lblMessage.Text = "Uploaded file details <hr />" & "File path on your Computer: " & strFileNameWithPath & "<br />" & "File Name: " & strFileName & "<br />" & "File Extension Name: " & strExtensionName & "<br />" & "File Size: " & intFileSize.ToString() FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Upload/") & strFileName) Else lblMessage.Text = "File size exceeded than limit 100 X 100, Please upload smaller file." End If Else lblMessage.Text = "File size exceeded than limit " & intFileSizeLimit & " KB, Please upload smaller file." End If Else lblMessage.Text = "Only .jpg or .gif file are allowed, try again!" lblMessage.ForeColor = System.Drawing.Color.Red End If End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5