In normal asp.net image uploader is working but in css the image uploader is not wrking.
Here is the code for image upload. But without css style the image is uploaded but with css the image is not uploding.
Upload.postfile is always false when css is applied
protected void Upload_Click(object sender, EventArgs e)
{
//if (FileUpload1.HasFile)
if (Upload.PostedFile != null)
{
string str = FileUpload1.FileName;
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Upload/" + str));
string Image = "~/Upload/" + str.ToString();
string name = TextBox1.Text;
SqlConnection con = new SqlConnection(@"Persist Security Info=False;User ID=sa;Pwd=1234;Initial Catalog=PATS_ING;Data Source=IBTSYS13\SQLEXPRESS");
SqlCommand cmd = new SqlCommand("insert into Image values(@ForeignKey,@ImagePath)", con);
cmd.Parameters.AddWithValue("@ForeignKey", 2);
cmd.Parameters.AddWithValue("ImagePath", Image);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
lblinfo.Text = "Image Uploaded";
lblinfo.ForeColor = System.Drawing.Color.ForestGreen;
}
else
{
lblinfo.Text = "Please Upload your Image";
lblinfo.ForeColor = System.Drawing.Color.Red;
}
}
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnsign" runat="server" type="submit" Text="Signature" class="col-sm-1 mr-2 btn btn-dark mt-4 mr-4" OnClick="Upload_Click" />
<input id="Upload" style="Z-INDEX: 102; LEFT: 104px; WIDTH: 288px; POSITION: absolute; TOP: 64px; HEIGHT: 22px" type="file" size="28" name="Upload" runat="server"/>
Upload Your Image:
<asp:Label ID="Label1" runat="server"></asp:Label>