1、可以通过前端进行解决,本案例通过后端解决的
判断请求的浏览器的ua,如果是ios浏览器则进行90度旋转
public function upload()
{
$file = $this->request->file('file');
if (empty($file)) {
$this->error(__('No file upload or server upload limit exceeded'));
}
//判断浏览器类型
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']));
//旋转90度
$image = imagerotate($image, -90, 0);
imagejpeg($image, $_FILES['file']['tmp_name']);
imagedestroy($image);
}catch(\Exception $e){
//echo $e->getMessage();
}
}