https://androidforums.com/threads/facebook-photo-upload-sideways.48934/
This happens because some cameras include EXIF info into pictures with wrong orientation. Android apps know how to correctly read this info, but other applications don't. Solution to this (as suggested on that forum) is to take pictures that you want to share over the Internet in landscape mode, not in portrait mode.