Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi all
i have a file upload in my webform and i allow the maximum file size to be uploaded in my application is 2MB, Configuration is done in web.config file.But on the file upload if file size is greater than 1MB and less than 2mb then in this condition i displayed alert box that file size exceeds than 1MB.
It is working fine on localhost but when i deployed it on live server this is not working
Code is here
C#
if (filFile.HasFile)
            {
                if (string.IsNullOrEmpty(script))
                {
                    //Uploaded file is valid, now we can do whatever we like to do, copying it file system,
                    //saving it in db etc.
                    try
                    {

                        if (filFile.HasFile)
                        {

                            int fileSize = filFile.PostedFile.ContentLength;
                            // if (fileSize > 1100000)
                            if (fileSize > 1024 * 1024)
                            {

                                Response.Write("<script> alert ('File size exceeds form 1MB.') </script>");
                                //Session["uploader_Else"] = "Else";
                                script = string.Format(SCRIPT_TEMPLATE, "File upload FAILED.", "false");
                                ClientScript.RegisterStartupScript(this.GetType(), "uploadNotify", script);

                            }
                            else
                            {
}


Kindly give me the reason why it is not working on live server although it is working fine on localhost.
Posted
Comments
ZurdoDev 1-Aug-13 9:10am    
Perhaps permissions. But debug it and tell us why it isn't working.
Silvabolt 1-Aug-13 12:04pm    
Check to see if your config is right, deployment usually entails changing your keys so maybe you did something wrong there. Can you provide us with SCRIPT_TEMPLATE?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900