Protected Sub btnFileUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strSaveFileAs As String
Dim strStatusMessage As String
strSaveFileAs = Server.MapPath("uploads/" & DateTime.Now.ToString("dd_MMM_yyyy hh_mm_ss tt") + myFileUpload.FileName)
lblFileName.Text = DateTime.Now.ToString("dd_MMM_yyyy hh_mm_ss tt") + myFileUpload.PostedFile.FileName
lblFileType.Text = myFileUpload.PostedFile.ContentType
lblFileSize.Text = myFileUpload.PostedFile.ContentLength
Try
If myFileUpload.HasFile Then
myFileUpload.SaveAs(strSaveFileAs)
strStatusMessage = "File saved as: " & strSaveFileAs
Else
strStatusMessage = "No file was uploaded."
End If
Catch Ex As Exception
strStatusMessage = "Unable to save the uploaded file. " _
& "The error was: " & Ex.Message
Finally
lblSaveResults.Text = strStatusMessage
End Try