Please can you tell me the units measured by InputFile.PostedFile.ContentLength . I need to make sure the file is less than 500k.
Thanks.
Please can you tell me the units measured by InputFile.PostedFile.ContentLength . I need to make sure the file is less than 500k.
Thanks.
                        
                            
                        
                        
                            On
                            
                            
                                                    
                    
                It's bytes.
http://msdn.microsoft.com/en-us/library/system.web.httppostedfile.contentlength.aspx
HttpPostedFile.ContentLength
Gets the size of an uploaded file, in bytes.
                        
                            
                        
                        
                            On
                            
                            
                                                    
                    
                
When i am uploading a template file of more than 1 mb its geting loaded for long time.my code is as below----
if (checkImagecount())
{
    //string imgFolder = Server.MapPath("/Userimages/" + emp_id.ToString().Trim() + "/Images/Browseimage/");
    string destinationImage = Server.MapPath("/master/" + emp_id.ToString().Trim() + "/Images/");
    string destination1 = Server.MapPath("/master/" + emp_id.ToString().Trim() + "/Images/");
    string imgFilename, fileExt = String.Empty;
    Response.Write(fileTemplateimage.PostedFile.ContentLength+"<br/>");
    Response.Write(fileTemplateimage.FileBytes.Length);
    Response.End();    
    if (fileTemplateimage.PostedFile.ContentLength > 0 && fileTemplateimage.FileBytes.Length <= 1048576)
    {
        System.Drawing.Image uploadImage = System.Drawing.Image.FromStream(fileTemplateimage.PostedFile.InputStream);
        float uploadImagewidth = uploadImage.PhysicalDimension.Width;
        float uploadImageheight = uploadImage.PhysicalDimension.Height;
else
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "failure", "alert('अपलोड फ़ाइल आकार 1 एमबी से अधिक नहीं होना चाहिए.');", true);
        divhide.Style.Add("display", "block");
        divUploadpanel.Style.Add("display", "block");
        fileTemplateimage.Focus();
                        
Unit of measurement = Byte.
Sample code testing for a file size of 15 KB:
In your case, as you want the file to be less than 500 KB, you should have this: