栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

PHP

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

PHP

AFAIK,您必须使用图像函数imagecreatefromstring,imagejpeg创建图像。

$imageData = base64_depre($imageData);$source = imagecreatefromstring($imageData);$rotate = imagerotate($source, $angle, 0); // if want to rotate the image$imageSave = imagejpeg($rotate,$imageName,100);imagedestroy($source);

希望这会有所帮助。

PHP CODE WITH IMAGE DATA

$imageDataEnpred = base64_enpre(file_get_contents('sample.png'));$imageData = base64_depre($imageDataEnpred);$source = imagecreatefromstring($imageData);$angle = 90;$rotate = imagerotate($source, $angle, 0); // if want to rotate the image$imageName = "hello1.png";$imageSave = imagejpeg($rotate,$imageName,100);imagedestroy($source);

因此,以下是程序的php部分..

NOTE
带注释的更改
Change is here

    $uploadedPhotos = array('photo_1','photo_2','photo_3','photo_4');     foreach ($uploadedPhotos as $file) {      if($this->input->post($file)){      $imageData = base64_depre($this->input->post($file)); // <-- **Change is here for variable name only**         $photo = imagecreatefromstring($imageData); // <-- **Change is here**                $this->session->set_userdata('upload_'.$file,'ant');                if(!$this->session->userdata('uploading_on_datetime')){         $this->session->set_userdata('uploading_on_datetime',time());        }         $datetime_upload = $this->session->userdata('uploading_on_datetime',true);                $new_dir = 'temp/user_'.$this->session->userdata('user_id',true).'_on_'.$datetime_upload.'/';        if(!is_dir($new_dir)){        @mkdir($new_dir);        }                // @file_put_contents( $new_dir.$file.'.jpg',imagejpeg($photo));        imagejpeg($photo,$new_dir.$file.'.jpg',100); // <-- **Change is here**      }    }


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/371085.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号