iPhone Orientation Issue

Images taken by iphone always show wrong orientation after upload to server. This is why. Fuck!

Reference:

iphone_orientation

exif example: (taken by iphone 5)

<pre>Array
(
    [FileName] => bc522572b9ed9f32d9f57dcb8fd120c5.jpg
    [FileDateTime] => 1492243697
    [FileSize] => 2337483
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS
    [COMPUTED] => Array
        (
             => width="3264" height="2448"
            [Height] => 2448
            [Width] => 3264
            [IsColor] => 1
            [ByteOrderMotorola] => 1
            [ApertureFNumber] => f/2.4
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
        )

    [Make] => Apple
    [Model] => iPhone 5
    [Orientation] => 3
    [XResolution] => 72/1
    [YResolution] => 72/1
    [ResolutionUnit] => 2
    [Software] => 10.0.2
    [DateTime] => 2017:04:15 15:47:57
    [YCbCrPositioning] => 1
    [Exif_IFD_Pointer] => 206
    [GPS_IFD_Pointer] => 1016
    [THUMBNAIL] => Array
        (
            [Compression] => 6
            [XResolution] => 72/1
            [YResolution] => 72/1
            [ResolutionUnit] => 2
            [JPEGInterchangeFormat] => 1420
            [JPEGInterchangeFormatLength] => 13367
        )

    [ExposureTime] => 1/20
    [FNumber] => 12/5
    [ExposureProgram] => 2
    [ISOSpeedRatings] => 160
    [ExifVersion] => 0221
    [DateTimeOriginal] => 2017:04:15 15:47:57
    [DateTimeDigitized] => 2017:04:15 15:47:57
    [ComponentsConfiguration] => 
    [ShutterSpeedValue] => 3799/879
    [ApertureValue] => 4845/1918
    [BrightnessValue] => 3615/1942
    [ExposureBiasValue] => 0/1
    [MeteringMode] => 5
    [Flash] => 24
    [FocalLength] => 103/25
    [SubjectLocation] => Array
        (
            [0] => 735
            [1] => 1675
            [2] => 231
            [3] => 232
        )

    [MakerNote] => Apple iOSMM	ht		�	�	
�	bplist00�YtimescaleUvalueUepochUflags;��n�7�!'-2;=	?�;�����V����(
    [SubSecTimeOriginal] => 867
    [SubSecTimeDigitized] => 867
    [FlashPixVersion] => 0100
    [ColorSpace] => 1
    [ExifImageWidth] => 3264
    [ExifImageLength] => 2448
    [SensingMethod] => 2
    [SceneType] => 
    [ExposureMode] => 0
    [WhiteBalance] => 0
    [FocalLengthIn35mmFilm] => 33
    [SceneCaptureType] => 0
    [UndefinedTag:0xA432] => Array
        (
            [0] => 103/25
            [1] => 103/25
            [2] => 12/5
            [3] => 12/5
        )

    [UndefinedTag:0xA433] => Apple
    [UndefinedTag:0xA434] => iPhone 5 back camera 4.12mm f/2.4
    [GPSLatitudeRef] => N
    [GPSLatitude] => Array
        (
            [0] => 24/1
            [1] => 57/1
            [2] => 5964/100
        )

    [GPSLongitudeRef] => E
    [GPSLongitude] => Array
        (
            [0] => 121/1
            [1] => 32/1
            [2] => 2447/100
        )

    [GPSAltitudeRef] => 
    [GPSAltitude] => 47200/1367
    [GPSTimeStamp] => Array
        (
            [0] => 7/1
            [1] => 47/1
            [2] => 5537/100
        )

    [GPSSpeedRef] => K
    [GPSSpeed] => 0/1
    [GPSImgDirectionRef] => T
    [GPSImgDirection] => 33149/140
    [GPSDestBearingRef] => T
    [GPSDestBearing] => 33149/140
    [GPSDateStamp] => 2017:04:15
    [UndefinedTag:0x001F] => 29678/199
)
</pre>