ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.[Solved] ASP.Net Error: image1 does not contain a definition for save<p>Hi&nbsp;milepredy,</p> <p>Refer&nbsp;the below code.&nbsp;</p> <p>First you need to convert the image url to&nbsp;Bitmap image then use the&nbsp;Bitmap Save method to assign it to the&nbsp;MemoryStream and convert it to byte array.</p> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">protected void btnUpload_Click(object sender, EventArgs e) { string folderPath = Server.MapPath(&#34;~/Files/&#34;); //Check whether Directory (Folder) exists. if (!Directory.Exists(folderPath)) { //If Directory (Folder) does not exists Create it. Directory.CreateDirectory(folderPath); } //Save the File to the Directory (Folder). FileUpload1.SaveAs(folderPath + Path.GetFileName(FileUpload1.FileName)); //Display the Picture in Image control. Image1.ImageUrl = &#34;~/Files/&#34; + Path.GetFileName(FileUpload1.FileName); } protected void btnInsert_Click(object sender, EventArgs e) { try { byte[] data; using (MemoryStream ms = new MemoryStream()) { System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(Server.MapPath(Image1.ImageUrl)); bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); data = ms.ToArray(); } using (MySqlConnection con = new MySqlConnection(myconstring)) { con.Open(); using (MySqlCommand command = new MySqlCommand(&#34;INSERT INTO image (picture) VALUES (@IM)&#34;, con)) { command.Parameters.AddWithValue(&#34;@IM&#34;, data); command.ExecuteNonQuery(); } } } catch (Exception ex) { } }</pre> <p><span style="text-decoration: underline;"><strong>VB.Net</strong></span></p> <pre class="brush: vb"> Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As EventArgs) Dim folderPath As String = Server.MapPath(&#34;~/Files/&#34;) If Not Directory.Exists(folderPath) Then Directory.CreateDirectory(folderPath) End If FileUpload1.SaveAs(folderPath &amp; Path.GetFileName(FileUpload1.FileName)) Image1.ImageUrl = &#34;~/Files/&#34; &amp; Path.GetFileName(FileUpload1.FileName) End Sub Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As EventArgs) Try Dim data As Byte() Using ms As MemoryStream = New MemoryStream() Dim bitmap As System.Drawing.Bitmap = New System.Drawing.Bitmap(Server.MapPath(Image1.ImageUrl)) bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg) data = ms.ToArray() End Using Using con As MySqlConnection = New MySqlConnection(myconstring) con.Open() Using command As MySqlCommand = New MySqlCommand(&#34;INSERT INTO image (picture) VALUES (@IM)&#34;, con) command.Parameters.AddWithValue(&#34;@IM&#34;, data) command.ExecuteNonQuery() End Using End Using Catch ex As Exception End Try End Sub</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/148630/Solved-ASPNet-Error-image1-does-not-contain-a-definition-for-save/https://www.aspforums.net:443/Threads/148630/Solved-ASPNet-Error-image1-does-not-contain-a-definition-for-save/Mon, 05 Aug 2019 05:59:40 GMT