I have seen this happen in the past when uploading very large attachments on a slow connection. I think this was on the old server, which enforced a 5 minute timeout on page loads, although these days my connection is fast enough that even when I upload the ~70MB styles ZIP to neolemmix.com - far larger than the forums allows attachments to be - it's done in well under 5 minutes anyway.
Did the page take a long time to load when doing this, or did it load at normal(ish) speed but then give the error?