CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Img Collection

  1. #1
    Join Date
    Jun 2016

    Img Collection


    In my ASP.NET Webform page, I have a fileuploader and a div. On single selection of image, the selected image is added to the div. All works fine. Now, I would like to add a checkbox or some sort of selection and then save the selected images to the server folder. Please can someone help on how to do it?


  2. #2
    Join Date
    Dec 2018

    Re: Img Collection

    try this code:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"Inherits="Byte_array_gridview._Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""">
    <html xmlns="" >
    <head id="Head1" runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
    Image File </td>
    <input id="Upload" type="file" runat="server" /></td>
    <asp:Button id="btn_insert" RunAt="server"
    Text="Insert" onclick="btn_insert_Click"></asp:Button>
    <asp:label id="lblMessage" runat="server" />

    For image
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.IO;
    using System.Data.SqlClient;
    namespace Byte_array_gridview
    public partial class image : System.Web.UI.Page
    string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    string str;
    SqlCommand com;
    protected void Page_Load(object sender, EventArgs e)
    SqlConnection con = new SqlConnection(strConnString);
    str = "select photo from employee where id = '" + Request.QueryString["id"] + "'";
    com = new SqlCommand(str, con);
    MemoryStream stream = new MemoryStream();
    byte[] image = (byte[])com.ExecuteScalar();
    stream.Write(image, 0, image.Length);
    Bitmap bitmap = new Bitmap(stream);
    Response.ContentType = "image/Jpeg";
    bitmap.Save(Response.OutputStream, ImageFormat.Jpeg);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)