Tag:ret div cti Address gpo encode exists base gif
/** * Get image Base64 encoding (URL not supported) * @param $img _file incoming local image address * @return string */function imgToBase64 ($img _file) {$img _base6 4 = "; if (file_exists ($img _file)) {$app _img_file = $img _file;//Picture path $img _info = getimagesize ($app _img_file);// Get pictures of size, type etc//echo ' <pre> '. Print_r ($img _info, True). ' </pre><br> '; $fp = fopen ($app _img_file, "R"); Whether the picture is readable permission if ($fp) {$filesize = FileSize ($app _img_file); $content = Fread ($fp, $filesize); $file _content = Chunk_split (Base64_encode ($content)); Base64 Code switch ($img _info[2]) {//Interpret picture type Case 1: $img _type = "gif"; Break Case 2: $img _type = "jpg"; Break Case 3: $img _type = "png"; Break } $img _base64 = ' data:image/'. $img _type. '; Base64, '. $file base64 encoding of _content;//synthetic images} fclose ($FP); } return $img _base64; Returns the method used by the base64}//call of the picture $img_dir = DirName (__file__). '/uploads/img/11213223.jpg '; $img _base64 = ImgToBase64 ($img _dir); Echo ' '; Echo '
PHP turns images into base64