Upload Correct Image Format and Size



In this Post Upload Correct Image Format and Size

Upload Button Click Coding
---------------------------

if (FileUpload1.HasFile == true)
        {

            String contenttype = FileUpload1.PostedFile.ContentType;

            if (contenttype == "image/jpeg")
            {
                int filesize;
                filesize = FileUpload1.PostedFile.ContentLength;

                if (filesize <= 51200)
                {
                    
                    FileUpload1.SaveAs(Server.MapPath("~/") + FileUpload1.FileName);
                    Image2.ImageUrl = FileUpload1.FileName;
                    Image1.ImageUrl = "~/success.png";
                    Label3.Text = "File Has Been Saved Successfully - See Below";

                }
                else
                {
                    Label3.Text = "File Size exceeds 50 KB - Please Upload File Size Maximum 50 KB";
                    Image1.ImageUrl = "~/errorsign.png";
                }

            }
            else
            {
                Label3.Text = "Only JPEG/JPG Image File Acceptable - Please Upload Image File Again";
                Image1.ImageUrl = "~/errorsign.png";
            }
        }
        else
        {
            Label3.Text = "You have not selected any file - Browse and Select File First";
            Image1.ImageUrl = "~/errorsign.png";
        }

0 Comment's

Comment Form

Submit Comment