Removing Large File Uploads

Before I start this blog can I ask that it doesn't turn in to a discussion about the accuracy of the this next statement --- of all the things that Domino is bad at it is particularly bad at handling attachments. Working with files in the browser is nothing short of a nightmare and an area that needs some serious thought on Lotus's part. Take a quick look at the posts on the Notes.net forum and see what I mean. I continually get asked questions about working with attachments. Two emails just yesterday.

As a developer it's often a case of knowing of the things like this. In this case both undocumented and one of which (%%Detach) only came my way via a chance email from a Lotus employee.

Anyway, enough controversy, on to something more useful. Earlier this week I got asked if I knew a way to elegantly handle the removal of files people upload if they are deemed too large. My initial (lazy) response was to suggest using the server's POST request size limit. This is anything but elegant though as it generates an error 500 and the user should never have to see an error! Instead I set about finding a better way. First using @Functions and then using LotusScript. As far as I know neither have been done before, although I have a horrible feeling somebody is about to prove me wrong. Here's what I came up with:

File upload form

Notice that there is a limit to the number of bytes you can upload. One megabyte in this case. In this shot I've just tried to upload something larger and it's telling me I can't. It works fairly well and I will try and write the article and make it available sometime today or over the weekend I've written an article about it. Hopefully, if one person asked, lots of people want.

Note: I toyed with the idea of placing a replica online for you to play with but I though better of it. While it limits the size of files there's nothing stopping you sending huge files my way and I don't want server performance to suffer. So you'll just have to wait ;o)


  1. Jake,

    You can also just put a hidden editable text field on the form and add the following to the Input Validation:

    @If(@Attachments=1;@If(@AttachmentLengths>20000;@Failure("<HTML><HEAD><TITLE>Web Page>Image Size Validation</TITLE><HEAD><FONT Face=verdana size=2><b>Image is too large</b><br><br>The image that you have selected is greater than 20K in size<br><br>Image size:"+@Text(@Round((@AttachmentLengths/1000)))+"K<br><br><a href=javascript:history.go(-1)>Click here to try again </a></font></HTML>");@Success);@Success)


    • avatar
    • Jake
    • Thu 19 Jun 2003 05:28

    You can but as I'm writing at the moment in the article, you wouldn't want to. The LotusScript method is much better.

    • avatar
    • Jorge
    • Thu 19 Jun 2003 07:32

    Check out the third Q&A on this page.


    • avatar
    • Jake
    • Thu 19 Jun 2003 07:49

    Thanks Jorge. This would be nice if you could gaurantee the access to install and run ActiveX objects or run .hta files. Not everybody can and it would probably be restricted to intranets...

  2. Jake -

    The problem I see: if this is handled by the server, the user is going to have to wait a long time for the file to upload, and then get a "sorry! can't do this" message. Wouldn't it be better to try to get the browser to figure this out using Javascript?

    Not that I practice what I'm preaching here... I use the dreaded validation field method that you are improving on. Look forward to the reasons why this is bad.


    • avatar
    • Jake
    • Thu 19 Jun 2003 09:24

    Sean, if you could do in JavaScript, trust me, I would have talked about it.

    The reason you can't is that it would require giving the browser access to the OS and that's a big no-no.

  3. Nice job, Jake!

    Thought you should have at least one unreserved pat on the back. :o)

    As for the user having to wait for a failure report, if the form clearly states the file size limit, as Jakes example shows, then shame on them for not looking at their file size before clicking Upload.

    Like an old collegue once told me, "Don't try to idiot proof your applications... the idiots won't appreciate it."


  4. A former Lotus employee ;-)

    • avatar
    • Jake
    • Fri 20 Jun 2003 06:23

    Sorry to hear that Sylvain. Did they get rid of you for sharing secrets? It should cheer you up to know how many people your little secret has helped.

    Glad to see you are still reading ;o)

  5. I left them on my own, I prefer yellow than blue ...

    But It's still a pleasure to read Codestore day after day !

  6. Hello!

    I was wondering if anyone was able to validate the size on an image file in pixels? For example, validate that an image is 150x150? I've done a brief javascript for it, but it is very temperamental.

    Any ideas?


    • avatar
    • arun
    • Mon 11 Jul 2005 02:25

    Dear Sir,

    how to upload files from java applet to lotus notes domino server.

    please send me the correct source code for that.

    Thanking you

    Yours R.Arun

Your Comments


About This Page

Written by Jake Howlett on Thu 19 Jun 2003

Share This Page

# ( ) '


The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social

About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content