示例#1
0
 public static function base64ToFile($base64, $save)
 {
     $base64 = substr($base64, strpos($base64, ',') + 1);
     $base64 = base64_decode($base64);
     if (!$base64) {
         throw new \Exception("Invalid base64 image string");
     }
     $file = new File();
     $file->setFileName($save);
     $file->setContents($base64);
     $file->write();
     ImageValidate::mustBeImage($file);
     return $file;
 }