side browser ios pictures uploaded to the server, the pictures are rotated 90 degrees php solutions

1, can be resolved through the front, in this case resolved by the back-end

Analyzing browser request ua, if ios browser 90 degree rotation is performed

 public function upload()
    {
        $file = $this->request->file('file');
        if (empty($file)) {
            $this->error(__('No file upload or server upload limit exceeded'));
        }
        // determine the type of browser
        if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
		    try{
				$exif = @exif_read_data($_FILES['file']['tmp_name']);
				$image = imagecreatefromstring(file_get_contents($_FILES['file']['tmp_name']));
				//Rotate 90 degrees
				$image = imagerotate($image, -90, 0);
			    imagejpeg($image, $_FILES['file']['tmp_name']);
			    imagedestroy($image);
			}catch(\Exception $e){
				//echo $e->getMessage();
			}
		}

  

 

Guess you like

Origin www.cnblogs.com/pxjbk/p/11869436.html