If you follow these rules it works 99% of the time.
Before posting an attachment, leave the page and come back (go to the prior page in the thread and then push LAST, or close the thread and reopen the last page, or etc). The page must be freshly loaded. My theory is this gets the javascript...