protected void submitbutton_Click(object sender, EventArgs e)
        {
            string filename     = productId + ".png";
            string savelocation = Server.MapPath("~/ProductImages/" + filename);

            ImageFileUploadControl.SaveAs(savelocation);
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string productId    = Request.QueryString["ProductID"];
            string filename     = productId + ".jpg";
            string saveLocation = Server.MapPath("~/Images/ProductImage/" + filename);

            ImageFileUploadControl.SaveAs(saveLocation);
        }
Exemple #3
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            //note much of the code to do this properly (i.e. check file type is correct) is missing

            //get the id from the query string (keeping it as a string is OK in this case)
            string ProductId = Request.QueryString["ProductId"];

            string filename     = ProductId + ".jpg";
            string saveLocation = Server.MapPath("~/ProductImages/" + filename);

            ImageFileUploadControl.SaveAs(saveLocation);
        }
Exemple #4
0
        protected void submitbutton_Click(object sender, EventArgs e)
        {
            //code to check correct file tyoe
            //get the id from the query string (keeping it as a string is ok in this case)
            string productId    = Request.QueryString["ProductID"];
            string filename     = productId + ".png";
            string savelocation = Server.MapPath("~/ProductImages/" + filename);

            ImageFileUploadControl.SaveAs(savelocation);

            Lerroralert.Text = "Image successfully uploaded!";
        }
        protected void UBtn_Click(object sender, EventArgs e)
        {
            string imgPath = Path.GetFileName(ImageFileUploadControl.FileName);

            string productID = Request.QueryString["productID"];

            string filename = productID + ".jpg";

            string saveLocation = Server.MapPath("~/ProductImage/" + filename);

            ImageFileUploadControl.SaveAs(saveLocation);

            SqlConnection CONS = new SqlConnection(@"Data Source = SQL2016.FSE.Network; Initial Catalog = db_1525597_co5027_asg; Integrated Security = False; User ID = user_db_1525597_co5027_asg; Password = Anaqi8156211; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False");

            CONS.Open();

            SqlCommand Cd = new SqlCommand("Insert into Productimg(ProductImage,ImageLocation)values(@ProductImage,@ImageLocation)", CONS);

            Cd.Parameters.AddWithValue("@ProductImage", filename);
            Cd.Parameters.AddWithValue("@ImageLocation", "~/ProductImage/" + filename);
            Cd.ExecuteNonQuery();
            CONS.Close();
        }