Photos taken with a smartphone or digital camera contain “Exif data,” all sorts of information about where the photo was taken, when it was taken, and even how the camera was oriented. When uploaded to File Manager, this data is preserved, and that can often cause the orientation of the picture to be rotated.
To prevent this, it’s necessary to remove the Exif data from the image before it is uploaded. There are free online tools available to do this, such as http://www.verexif.com/en/. Once you scrub the Exif data, you can rotate the picture and it will remain in the correct orientation when it is uploaded.