dongxiong1935 2017-10-07 05:42 采纳率: 0%
浏览 4731

从base64_decode图像中获取文件名

图像将从 mobile api 中的 base64 类型,我正在尝试从中获取图像名称 base64_decoded图像文件。我怎样才能得到它?

$data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl'
       . 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr'
       . 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r'
       . '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
$data = base64_decode($data);

$im = imagecreatefromstring($data);

这是我的功能,试图获取用laravel编写的图像名称

   public function completeProfile($session_id,$username,$fullname,$position,$image){
      $user = JWTAuth::toUser($session_id);
      $userid = $user->id;
      $img = base64_decode($image);
      if(file_put_contents(public_path().'/images/users',$img)){
          $result = $this->repository->completeProfile($userid,$username,$fullname,$position,$image);
      }
      return false;
}
  • 写回答

2条回答 默认 最新

  • dongqiangse6623 2017-10-07 05:47
    关注

    It is not possible to get the filename from base64 format, as this only contains the data that makes up the image, not it's metadata.

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条