Garima Bansal

Garima Bansal

  • 1k
  • 694
  • 41.4k

save image in bytearray

Jan 16 2023 11:54 AM

i want to upload image and save in database as byte[]

1: working on registration form in which i have other fields also

<div class="row">
    <div class="col-sm-4">
        <span id="lblname" class="form-control border-0">Name of the Applicant<b style="color: red;">*</b></span>
    </div>
    <div class="col-sm-8">
        <asp:TextBox ID="txtname" runat="server" CssClass="form-control"></asp:TextBox>
    </div>
</div>

 <div class="row">
    <div class="col-sm-4">
        <span id="lbladress" class="form-control border-0">Address<b style="color: red;">*</b></span>
    </div>
    <div class="col-sm-8">
        <asp:TextBox ID="txtadress" runat="server" CssClass="form-control"></asp:TextBox>
    </div>
</div>

<div class="row">
    <div class="col-sm-4">
        <span id="lblemail" class="form-control border-0">Email<b style="color: red;">*</b></span>
    </div>
    <div class="col-sm-8">
        <asp:TextBox ID="txtemail" runat="server" CssClass="form-control"></asp:TextBox>
    </div>
</div>

 <div class="row">
    <div class="col-sm-4">
        <span id="lblphoto" class="form-control border-0">Photograph<b style="color: red;">*</b></span>
    </div>
    <div class="col-sm-8">
    <asp:FileUpload id="FileUpLoad2" runat="server" />  
    </div>
</div>
var db = new DatabaseContext();
var applicant = new Applicant();
applicant.Name = txtname.Text;
applicant.Address = txtadress.Text;
applicant.Email = txtemail.Text;
db.Applicant.Add(applicant);
db.SaveChanges();
}

Now,how can i implement?


Answers (3)