Ejemplo n.º 1
0
        private void uploadPic()
        {

            if (FUCPic.FileBytes.Length == 0)
                return;
            string ext = System.IO.Path.GetExtension(FUCPic.FileName).TrimStart(".".ToCharArray()).ToLower();
            if ((ext != "jpeg") && (ext != "jpg") && (ext != "png") && (ext != "gif") && (ext != "bmp"))
            {
                return;
            }

            Bitmap uploadedImage = new Bitmap(FUCPic.FileContent);

            int maxWidth = 480;
            int maxHeight = 0;

            // Resize the image
            ManagePicture te = new ManagePicture();
            Bitmap resizedImage = te.GetScaledPicture(uploadedImage, maxWidth, maxHeight);



            String virtualPath = "~/image/ManageFontEnd/workbranch/" + System.Guid.NewGuid().ToString() + "." + ext;

            String tempFileName = Server.MapPath(virtualPath);
            resizedImage.Save(tempFileName, uploadedImage.RawFormat);

            picturPath = virtualPath.ToString();
        }
Ejemplo n.º 2
0
        public Options(string bannerName)
        {
            InitializeComponent();
            UserBanner.Text = bannerName;
            myName          = giveName(bannerName);


            //string SelectAdmin = "Admin";

            myLogin lgn = new myLogin();

            string OptionsUserName = lgn.Get_login_username();

            MySqlConnection connect = new MySqlConnection("server = localhost; database = mega; username = root; password=;");

            string query = "select* from LoginPage where username = '******' ";


            MySqlDataAdapter data = new MySqlDataAdapter(query, connect);

            DataTable DT = new DataTable();

            data.Fill(DT);


            if (DT.Rows[0][3].ToString().Trim() == "Admin")

            {
                ManagePicture.Show();
                ManageLabel.Show();
            }
            else
            {
                ManagePicture.Hide();
                ManageLabel.Hide();
            }
        }
Ejemplo n.º 3
0
  /*   protected void UploadButton_Click(object sender, EventArgs e)
        {
            // Validate the uploaded file
            // 1. The uploaded file should not be a blank file
            if (FUCPic.FileBytes.Length == 0)
                return;
            // 2. The uploaded file should be having one of the allowed extensions
            string ext = System.IO.Path.GetExtension(FUCPic.FileName).TrimStart(".".ToCharArray()).ToLower();
            if ((ext != "jpeg") && (ext != "jpg") && (ext != "png") && (ext != "gif") && (ext != "bmp"))
            {
                return;
            }

            // Validation successful
            // Load the image into Bitmap Object
            Bitmap uploadedImage = new Bitmap(FUCPic.FileContent);

            // Set the maximum width and height here.
            // You can make this versatile by getting these values from
            // QueryString or textboxes
            int maxWidth = 480;
            int maxHeight = 0;

            // Resize the image
            ManagePicture te = new ManagePicture();
            Bitmap resizedImage = te.GetScaledPicture(uploadedImage, maxWidth, maxHeight);

           // string picturename = FUCUpload.FileName;//picture Name:
            //Save the image

            String virtualPath = "~/image/ManageFontEnd/branchNews/" + System.Guid.NewGuid().ToString() + "." + ext;
       
            String tempFileName = Server.MapPath(virtualPath);
            resizedImage.Save(tempFileName, uploadedImage.RawFormat);


           // picturPath = virtualPath.ToString();
            //imgPic.ImageUrl = virtualPath;
         imgPic.ImageUrl="C:/Users/Public/Pictures/Sample Pictures/Lighthouse.jpg";
           imgPic.Visible = true;
        }
   * */
     private void uploadPic() {

         // Validate the uploaded file
         // 1. The uploaded file should not be a blank file
         if (FUCPic.FileBytes.Length == 0)
             return;
         // 2. The uploaded file should be having one of the allowed extensions
         string ext = System.IO.Path.GetExtension(FUCPic.FileName).TrimStart(".".ToCharArray()).ToLower();
         if ((ext != "jpeg") && (ext != "jpg") && (ext != "png") && (ext != "gif") && (ext != "bmp"))
         {
             return;
         }

         // Validation successful
         // Load the image into Bitmap Object
         Bitmap uploadedImage = new Bitmap(FUCPic.FileContent);

         // Set the maximum width and height here.
         // You can make this versatile by getting these values from
         // QueryString or textboxes
         int maxWidth = 480;
         int maxHeight = 0;

         // Resize the image
         ManagePicture te = new ManagePicture();
         Bitmap resizedImage = te.GetScaledPicture(uploadedImage, maxWidth, maxHeight);

         // string picturename = FUCUpload.FileName;//picture Name:
         //Save the image


         String virtualPath = "~/image/ManageFontEnd/branchNews/" + System.Guid.NewGuid().ToString() + "." + ext;

         String tempFileName = Server.MapPath(virtualPath);
         resizedImage.Save(tempFileName, uploadedImage.RawFormat);

         // Load the resized image on the browser

         // test.InnerHtml="<img src=../../../image/ButHome1.png /> </br> xxxxxxxx";
         // dimgPic.InnerHtml = "<img src=" + virtualPath + " /> ";
         picturPath = virtualPath.ToString();
       //  imgPic.ImageUrl = virtualPath;
        // imgPic.Visible = true;
     }
Ejemplo n.º 4
0
        private void uploadPic()
        {
            string ext = System.IO.Path.GetExtension(FUCPic.FileName).TrimStart(".".ToCharArray()).ToLower();
            if ((ext != "jpeg") && (ext != "jpg") && (ext != "png") && (ext != "gif") && (ext != "bmp"))
            {
                return;
            }
            Bitmap uploadedImage = new Bitmap(FUCPic.FileContent);

            int maxWidth = 620;
            int maxHeight = 240;

            ManagePicture te = new ManagePicture();
            Bitmap resizedImage = te.GetScaledPicture(uploadedImage, maxWidth, maxHeight);


            string ranPic = System.Guid.NewGuid().ToString() + "." + ext;

            String virtualPath = "~/image/ManageFontEnd/SlideShow/" + ranPic;
            string pathImgSave = "../../image/ManageFontEnd/SlideShow/" + ranPic;

            String tempFileName = Server.MapPath(virtualPath);
            resizedImage.Save(tempFileName, uploadedImage.RawFormat);
            picturPath = pathImgSave.ToString();
        }