I’ve been spending a considerable amount of time in fixing the WordPress error: An error occurred in the upload. Please try again later. I received this error when trying to add image upload functionality to my own custom plugin.
Then I remembered the obvious. The media upload element uses Ajax for uploading and return information about the uploaded image.
I assume you have WP_DEBUG = true in your config file, if not, make sure to add it to wp-config.php.
After that, use FireFox or Chrome developer tools and monitor the Ajax requests. You’ll notice requests to admin-ajax.php and async-upload.php. By looking at the responses the error was obvious, there was a conflict with (in my case, the custom permalink plugin) which gave me notices in the Ajax response. When I changed some code, it was solved and uploading media worked great!
So if you want to debug the mentioned issue, then make sure to monitor the Ajax requests, you might find the cause. Good luck and feel free to ask in case you need help!