I had managed to let users upload the image and save into the database and the folder. I need to generate thumbnail from the image and save into the database and the folder as well. But there is some error with generating thumbnail. Can someone help with me with it? Thank you

protected void Button1_Click(object sender, EventArgs e)
        {
            //Get Filename from fileupload control
            string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
            //Save images into Images folder
            FileUpload1.SaveAs(Request.MapPath("/Images/uploaded/" + filename));
            //Getting dbconnection from web.config connectionstring
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
            using (SqlDataAdapter adapter = new SqlDataAdapter("select ImageName from Images", connection))
            //Open the database connection
            {
                DataTable dt = new DataTable();
                adapter.Fill(dt);
                DataList1.DataSource = dt;
                DataList1.DataBind();
            }
            connection.Open();
            //Query to insert images path and name into database
            SqlCommand cmd = new SqlCommand("Insert into Images(ImageName) values(@ImageName)", connection);
            //Passing parameters to query
            cmd.Parameters.AddWithValue("@ImageName", filename);
            cmd.ExecuteNonQuery();
            //Close dbconnection
            connection.Close();
            string strImage = FileUpload1.FileName.ToString();
            if(FileUpload1.HasFile)
            {
            strImage = FileUpload1.FileName.ToString();
            //check whether the file exists or not
            if (!File.Exists(Request.MapPath("/Images/uploaded/") + strImage)) //testing
            {
            
           //create a new file name with grid
                strImage = Guid.NewGuid().ToString().Substring(0,8) + strImage.Substring(strImage.IndexOf('.'));
      
            }
            //save the file
            FileUpload1.SaveAs(Request.MapPath("/Images/uploaded/") + strImage); //testing
            // create an image object, using the filename we just retrieved
            System.Drawing.Image image = System.Drawing.Image.FromFile(Request.MapPath("/Images/uploaded/"));
            // create the actual thumbnail image
            System.Drawing.Image thumbnailImage = image.GetThumbnailImage(64, 64, new                                 System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
            // make a memory stream to work with the image bytes
            MemoryStream imageStream = new MemoryStream();
            // put the image into the memory stream
            thumbnailImage.Save(imageStream, System.Drawing.Imaging.Imageformat.Jpeg);
      
            } 
         }

Error message - The name 'ThumbnailCallback' does not exist in the current context.
The type or namespace name 'Imageformat' does not exist in the namespace 'System.Drawing.Imaging' (are you missing an assembly reference?).
Do I need to create a folder to store the thumbnail?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.