none
save image RRS feed

  • Question

  • I have a problem with adding images to the database, everything works fine but when I record in the database unless it is recorded images, and there is a value of "NULL". What is the problem ??

     

    protected void btnSave_Click(object sender, EventArgs e)
    {
    Customers cust = new Customers();
    cust.Name = txtName.Text;
    cust.Surname = txtSurname.Text;
    cust.Adress = txtAdress.Text;
    cust.Tel = txtTel.Text;
    cust.Email = txtEmail.Text;
    if (fuPhoto.PostedFile != null)
    {
    string filePath = fuPhoto.PostedFile.FileName;
    string filename = Path.GetFileName(filePath);
    string ext = Path.GetExtension(filename);
    string contenttype = String.Empty;
    switch (ext)
    {
    case ".jpg":
    contenttype = "image/jpg";
    break;
    case ".png":
    contenttype = "image/png";
    break;
    case ".gif":
    contenttype = "image/gif";
    break;
    }
    if (contenttype != String.Empty)
    {

    Stream fs = fuPhoto.PostedFile.InputStream;
    BinaryReader br = new BinaryReader(fs);
    Byte[] bytes = br.ReadBytes((Int32)fs.Length);
    }
    }

    Customersmodel.saveC(cust);

    Sunday, August 7, 2011 12:59 PM

Answers

All replies