protected void lbtnUploadPortfolio_Click(object sender, EventArgs e) { int accountid = int.Parse(Request.QueryString["ID"]); int imageSize; string fileExtension; string imgType; string imgName; try { if (uploadPortfolio.HasFile) { imageSize = uploadPortfolio.PostedFile.ContentLength; byte[] imageData = new byte[imageSize]; uploadPortfolio.PostedFile.InputStream.Read(imageData, 0, imageSize); imgName = uploadPortfolio.PostedFile.FileName; imgType = uploadPortfolio.PostedFile.ContentType; fileExtension = imgName.Substring(imgName.LastIndexOf(".")); fileExtension = fileExtension.ToLower(); if (fileExtension == ".jpg" || fileExtension == ".jpeg" || fileExtension == ".png") { int updateDB = procedure.updatePortfolioPic(accountid, imgName, imgType, imageData, imageData.Length); Response.Redirect("ArtistLandingPage.aspx?ID=" + accountid); } else { Response.Write("<script>alert('This site does not accept the file type you uploaded. Please submit a .jpg, .jpeg or .png file.')</script>"); } } } catch (Exception ex) { } }