Bug in Telligent.Glow.MultipleFileUpload Control

rated by 0 users
This post has 4 Replies | 2 Followers

Top 75 Contributor
Posts 287
Points 4,270
jeffesp Posted: Fri, Jul 18 2008 3:29 PM

There is an issue with the MultipleFileUpload control that makes it only be able to upload 4MB files.  The constructor looks like this:

public MultipleFileUpload()
{
    this.? = new HttpRuntimeSection().MaxRequestLength;
}

Since it is newing an HttpRuntimeSection each time, it will always get back 4096.  This wouldn't be so bad if the set of the AllowdFileSize property didn't look like this:

if (value < this.?)
{
    this.ViewState[?.?("???????????????")] = value;
}

where it checks to see if the value you are setting is less than the size configured in the constructor.  So you are limited to 4MB files to be uploaded with the multifile uploader.

 

--
--Jeff (ATGi)
  • | Post Points: 20
Top 75 Contributor
Posts 251
Points 3,855
Edoardo replied on Fri, Jul 18 2008 7:53 PM

I don't understand the code above but, yes, the multiple upload file control has a bug.
Even if you change the MaxRequestLenght in the web.config it won't allow you to upload file bigger than 4096bytes.

http://dev.communityserver.com/forums/p/499345/620747.aspx#620747

:)

Bye.
Dodo.

Running CS 2008.5 SP1 (v4.1.31106.3070) on Windows Server 2008 RTM and SQL2005 w/SP2.

  • | Post Points: 20
Top 75 Contributor
Posts 287
Points 4,270
jeffesp replied on Mon, Jul 21 2008 8:19 AM

Yeah the code is bit funky because it comes out of reflector and there is some obfuscation done on the dll that the control is in.  Thanks for the link, I had done a search but didn't find that thread.  I have a hack that works around if you are interested.

--
--Jeff (ATGi)
  • | Post Points: 20
Top 75 Contributor
Posts 251
Points 3,855
Edoardo replied on Tue, Aug 12 2008 8:40 PM

Uh! Yup! I'm interested... Smile

Bye.
Dodo.

Running CS 2008.5 SP1 (v4.1.31106.3070) on Windows Server 2008 RTM and SQL2005 w/SP2.

  • | Post Points: 20
Top 75 Contributor
Posts 287
Points 4,270
jeffesp replied on Wed, Aug 13 2008 7:33 AM

You need to create a new control that inherits from Telligent.Glow.MultipleFileUpload, and then replace the <TWC:MultipleFileUpload> controls in your site.  The code for the new control should look like this:

using System;
using System.Reflection;
using TG = Telligent.Glow;

namespace ATGi.CS.Controls
{
    public class MultipleFileUpload : TG.MultipleFileUpload
    {
        public MultipleFileUpload()
            : base()
        {
            // HACK: Find the integer field on this and set to a much larger maximum.
            // This is fragile and will probably break at some point with a new version of TWC:MultipleFileUpload.
            FieldInfo[] fis = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
            foreach (FieldInfo f in fis)
            {
                if (f.FieldType == typeof(int))
                    f.SetValue(this, 10485760); // value is in KB ~ 10GB should be enough (as should 640K).
            }
        }
    }
}

--
--Jeff (ATGi)
  • | Post Points: 5
Page 1 of 1 (5 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com