Frequently Asked Questions

Oct 21, 2020 - 02:22pm

 [F] Frequently Asked Questions  / Operational Questions  /

Can I Limit the Size of Incoming Attachments?

Rate This FAQ
 (Not yet rated)

Created On: 23 Jul 2001 7:10 am
Last Edited: 4 Mar 2013 10:32 am

Question Email This Printer Friendly

I would like to limit the size of attachments (enclosures) posted by my users. How can I do this?


You may limit the size of incoming attachments posted by email or via NNTP in their respective control panels ("Maximum size of incoming messages, including attachments").

In version 4.1+ you may set the "Maximum size for Web-based attachments:" in the General Control Panel.

Pre version 4.1, there is no built in way to restrict this for posts coming in from the Web.

The problem is that until the browser sends the full attachment, there is no way to know what the attachment size actually is. That said, while you can't block the browser from sending the entire attachment to Web Crossing, once it get to WebX you can prevent its being posted into the system by using filter macros.

This solution requires the use of two filter macros. Filter macro options and usage are described in your sysop documentation.

The maximum size of allowed attachments is hard coded to 1meg (1024000) in this example. You may alter this as you see fit, or substitute a site.variable that you can adjust "on the fly" from some other location.

To block attachments to discussions:

%% macro discussionAddFilterPre %%
     %%if form.enclosures.count > 1024000 %%
          <html>Attachment too Big!</html>
     %% endif %%
%% endmacro %%

To block attachments from messages:

%% macro messageAddFilterPre %%
     %%if form.enclosures.count > 1024000 %%
          <html>Attachment too Big!</html>
     %% endif %%
%% endmacro %%

Add these to your webx.tpl (or, if you already have existing message
or disccusion prefilter macros, then append the core code of these
examples to those), save and finally "Reset file cache for HTML files
and webx.tpl templates."