change the ajax attribute async to false, avoid the page being closed before upload finish.