SlickUpload
Welcome Guest Search | Active Topics | Log In | Register

File size limit error Options
ziskko
#1 Posted : Friday, May 16, 2008 8:20:08 AM
Rank: Newbie

Groups: Registered

Joined: 5/16/2008
Posts: 3

I want to limit the size of the uploaded files, and show an error if the file is bigger than this limit.

I put the parameter "<httpRuntime maxRequestLength="10240" executionTimeout="300"/>" in the web.config.

The problem is that when the file is bigger than the limit, the browser shows an error page like "Internet Explorer can not display the webpage ..." the execution of the application stops, and do not continue with the code that checks the upload status to show an error message if the upload fails.

This is the code of the Upload button:


protected void submitButton_Click(object sender, EventArgs args)
{

       

        UploadStatus status = HttpUploadModule.GetUploadStatus();

 

        if (status != null)

        {

            uploadPanel.Visible = false;

            uploadResultsPanel.Visible = true;

            ReadOnlyCollection <UploadedFile> files;

            if (status.Reason == UploadTerminationReason.NotTerminated)

            {

                resultsMessage.InnerText = "Upload completed successfully. The following files were uploaded:";

 

                resultsRepeater.DataSource = status.GetUploadedFiles();

                files = status.GetUploadedFiles();

                string a = files[0].ClientName;

                string b;

                files[0].LocationInfo.TryGetValue("fileName",out b);

                int registros = 0;

                ActionProcedures.ApFicherosCongresoInsertar(((clsSession)this.Session["Idsession"]).Usuario, idFolder, files[0].ClientName, Folder + "/" + idFolder + "/" + b.Substring(b.LastIndexOf("\\")+1), files[0].ContentType, 0, ref registros);

                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "reload", "<script type='text/javascript'>window.opener.reloadFiles('" + idFolder + "');</script>");

                resultsRepeater.DataBind();

            }

            else

            {

                if (status.Reason == UploadTerminationReason.Disconnected)

                {

                    resultsMessage.InnerText = "Upload was cancelled.";

                }

                else

                {

                    resultsMessage.InnerHtml = "Upload resulted in an error.<br />Reason:" + status.Reason.ToString() + "<br />Message:" +

                        status.ErrorMessage;

                }

                resultsMessage.Style["color"] = "red";

            }

     }

}

ChrisHynes
#2 Posted : Friday, May 16, 2008 12:03:41 PM
Rank: Administration


Groups:

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ
What version of SlickUpload are you using? Are you using the UploadManager control?
ziskko
#3 Posted : Monday, May 19, 2008 2:36:47 AM
Rank: Newbie

Groups: Registered

Joined: 5/16/2008
Posts: 3
The version is SlickUpload-4.0.1, and I am using the ProgressDisplay control.
ziskko
#4 Posted : Tuesday, May 20, 2008 2:43:14 AM
Rank: Newbie

Groups: Registered

Joined: 5/16/2008
Posts: 3
I have just solved the problem. I have changed the ProgressDisplay by a Custom UploadManager, and I have controled the result of the upload whith the OnUploadComplete event.

Thanks for all.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.