I used the jQuery Form plugin for asynchronous form submission. For forms that contain files, it copies the form to a hidden iframe, submits it, and copies back the iframe\'
You can't get page headers by JS, but you can distinguish error from success: Try something like this:
On server side:
/* file: upload.php */ '; if(success) print 'window.parent.OnUploadComplete(1,"File uploaded!");'; else print 'window.parent.OnUploadComplete(0, "File too large!");'; print ''; ?>