public function Base64EncodeImage ($ ImageFile) {// pictures base64 format conversion, image needs locally, have access, relative to the project path IF (file_exists ($ ImageFile) || is_file ($ ImageFile)) { $ image_info = getimagesize ($ ImageFile); $ the image_data = fread (the fopen ($ ImageFile, ' R & lt ' ), filesize ($ ImageFile)); $ base64_image = ' Data: ' . $ image_info [ ' MIME ' ]. ' ; Base64, ' chunk_split (the base64_encode. ($ the image_data)); return $ base64_image; }else { return -100; } }