Because of this Flash Player security restriction, you have to call featureLayer.addAttachment() after a button click. For example, if you have a button letting them choose a file using a FileReference, you need to have another button click before you call addAttachment(). You can't call it directly in the fileReference's complete event handler.