@Nick is the one with all the back end knowledge and know-how, so he may have more insight.
I have had similar issues with photos taken on a couple of my phones. One I had several years ago and one I had more recently. What works for me when it happens is batch editing all my photos before uploading them. I use a Mac, so I just import the ones I intend to use for a trip report to the Photos program, rotate them all 4 times on there, save, then export. The exported ones always come through rotated correctly.
There's just something about the way certain camera software creates image data that doesn't come out right when you upload images here.