I think you could be banging your head for a long time trying to find a javascript solution (been there, done that). This type of problem should be solved on the server side.
I have not worked with the ImageGallery yet, but I suspect that the upload of images comes with a server event that can be caught (if not, then you can create one). At that time, you should be able to access your sub-domains and save to the appropriate folder. Since they are on different servers you may have to look at how to transfer the data from the view content domain to the edit content domain.
It strikes me that your architecture may be more complicated than it needs to be. Can you not host all functionality on one web server (with the same web application) and implement roles to allow view, add, update and delete functionality to decide who gets to do what?
Just a thought.
Mark