getting difficulty to store the image in the give path and because the image is not store in the database it not shown in the web page
<asp:FileUpload ID="fuMultipleImage" runat="server" AllowMultiple="true" />
public void InsertMultipleImage()
{
BindDetails();
foreach (HttpPostedFile postedFile in fuMultipleImage.PostedFiles)
{
string filename = Path.GetFileName(postedFile.FileName);
string targetPath = Server.MapPath("~/Co-Working/Images/" + filename);
Stream strm = fuMultipleImage.PostedFile.InputStream;
var targetFile = targetPath;
fuMultipleImage.SaveAs(Server.MapPath("~/Co-Working/Images/" + targetPath));
string constr = ConfigurationManager.ConnectionStrings["IECNEWConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
string query = "insert into tblFiles values (@Name, @ContentType, @Data, @CoworkingId)";
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.Connection = con;
cmd.Parameters.AddWithValue("@Name", filename);
cmd.Parameters.AddWithValue("@ContentType", "~/Co-Working/Images/" + filename);
cmd.Parameters.AddWithValue("@Data", 0);
cmd.Parameters.AddWithValue("@CoworkingId", ViewState["ID"]);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
}
1 property-detail-02.jpg Images\p\property-detail-02.jpg 0x00000000
12 property-detail-03 (1).jpg Images\p\property-detail-03 (1).jpg 0x00000000
13 property-detail-02.jpg F:\Projects\India Entrepreneur Club\Backup\30-09-2017\IEC\Co-Working\Images\p\property-detail-02.jpg 0x00000000
34 property-detail-03 (1).jpg F:\Projects\India Entrepreneur Club\Backup\30-09-2017\IEC\Co-Working\Images\p\property-detail-03 (1).jpg 0x00000000
35 property-detail-02.jpg F:\Projects\India Entrepreneur Club\Backup\30-09-2017\IEC\Co-Working\Images\property-detail-02.jpg 0x00000000
46 property-detail-03.jpg F:\Projects\India Entrepreneur Club\Backup\30-09-2017\IEC\Co-Working\Images\property-detail-03.jpg 0x00000000
47 Deepa kar.jpg F:\Projects\India Entrepreneur Club\Backup\30-09-2017\IEC\Co-Working\Images\p\Deepa kar.jpg 0x00000000
58 HUsain-Bolt.jpg F:\Projects\India Entrepreneur Club\Backup\30-09-2017\IEC\Co-Working\Images\p\HUsain-Bolt.jpg 0x00000000
59 sakshi.jpg F:\Projects\India Entrepreneur Club\Backup\30-09-2017\IEC\Co-Working\Images\p\sakshi.jpg 0x00000000
510 Sitves sindhu.jpg F:\Projects\India Entrepreneur Club\Backup\30-09-2017\IEC\Co-Working\Images\p\Sitves sindhu.jpg 0x00000000
511 IMG_20170910_105600-min.jpg Images/p/IMG_20170910_105600-min.jpg 0x00000000
712 IMG_20170909_223610-min.jpg Images/p/IMG_20170909_223610-min.jpg 0x00000000
813 1.jpg Images/p/1.jpg 0x00000000
914 1.jpg Images/p/1.jpg 0x00000000
915 a.jpg Images/p/a.jpg 0x00000000
1116 a.jpg Images/p/a.jpg 0x00000000