Upload image to server using C#/.NET and storing filename in DB

前端 未结 2 575
小蘑菇
小蘑菇 2021-01-19 19:06

I\'m currently using the following snippet to insert data into a table in my database. It works great. But, I want to start adding filename data and not sure how to proceed.

2条回答
  •  隐瞒了意图╮
    2021-01-19 19:37

    To store the file in an images folder, it should be:

    FileUpload1.SaveAs(Server.MapPath("~/Images/" + FileUpload1.FileName));
    

    and then add the command parameters in the fileName

    comm.Parameters["@FileName"].Value = FileUpload1.FileName;
    

    Note: you must have the FileName field in your DB table.

提交回复
热议问题