Protected Sub UploadImage(ByVal sender As Object, ByVal e As EventArgs) Try Dim saveDir As String = ConfigurationManager.AppSettings.Item("BaseApplicationFolder") ' Get the physical file system path for the currently ' executing application. Dim appPath As String = Request.PhysicalApplicationPath If Not FACID = txtFacId.Text And Not String.IsNullOrEmpty(txtFacId.Text) Then FACID = txtFacId.Text End If ' Before attempting to save the file, verify ' that the FileUpload control contains a file. If (fuImage.HasFile) Then Dim savePath As String = appPath + "_images\assisted_living\fac_profile_pic\" + _ Server.HtmlEncode(fuImage.FileName) If fuImage.FileName.Contains(FACID) Then ' Call the SaveAs method to save the uploaded file to the specified path. ' If a file with the same name already exists in the specified path, the uploaded file overwrites it. If (File.Exists(savePath)) Then File.Delete(savePath) End If fuImage.SaveAs(savePath) Fac_picture.ImageUrl = "..\..\_images\assisted_living\fac_profile_pic\" + FACID + ".jpg" Response.Cache.SetCacheability(HttpCacheability.NoCache) Else lbl_message.Text = "The image name and facility name should match." End If End If Catch ex As Exception lbl_message.Text = ex.Message Finally Response.Redirect("UpdateFacilityProfile.aspx?FACID=" & FACID) End Try End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)