Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (FileUpload1.HasFile)
- protected void UploadButton_Click(object sender, EventArgs e)
- {
- string saveDir = @"~Visual Studio 2015ProjectsEMPMISPASSPORTS";
- string MainPath = Request.PhysicalApplicationPath;
- string EMPLOYEEID = TXTEMPID.Text;
- string UserFile = FileUpload1.FileName;
- if (FileUpload1.HasFile)
- {
- string savePath = MainPath + EMPLOYEEID + Server.HtmlEncode(UserFile);
- // Append the name of the file to upload to the path.
- //string EMPLOYEEID = TXTEMPID.Text;
- // savePath += fileName + EMPLOYEEID;
- FileUpload1.SaveAs(savePath);
- UploadStatusLabel.Text = "Your file was saved as " + UserFile;
- }
- else
- {
- UploadStatusLabel.Text = "You did not specify a file to upload.";
- }
- }
- <asp:Label ID="lblmsg" runat="server" Style="color: black; font-weight: bold; font-size: large;"
- Text="Image Uploaded." />
- <asp:FileUpload ID="fupidproof" runat="server" />
- <asp:HiddenField ID="hdidproof" runat="server" />
- <asp:Button ID="btnidproof" runat="server" Text="Upload" Style="background-color: darkcyan;
- color: white;" OnClick="btnidproof_Click" />
- --------------------------------aspx.cs code---------------------
- protected void btnidproof_Click(object sender, EventArgs e)
- {
- string str = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
- SqlConnection con = new SqlConnection(str);
- cmd.CommandType = CommandType.StoredProcedure;
- SqlCommand cmd = new SqlCommand("ProcedureName", con);
- string logopath = "";
- if (fupidproof.HasFile)
- {
- logopath = "~//Kycimg//" + Guid.NewGuid() + fupidproof.FileName;
- hdidproof.Value = logopath.ToString();
- fupidproof.SaveAs(Server.MapPath(logopath));
- }
- cmd.Parameters.AddWithValue("@Image", hdidproof.Value, SqlDbType.VarChar);
- cmd.ExecuteNonQuery();
- lblMessage.Text = "Image has been Uploaded Successfully";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement