我将图像保存为二进制数据库。我想在MPDF中显示此图像。正常图像显示工作正常但二进制图像无法显示
我使用的代码是
<td><img style="vertical-align: top" src="'.$studphoto.'" width="80" /></td>
我在插入数据库时使用的代码是
$photo_get = file_get_contents($_FILES["photo"]["tmp_name"]);
list($width, $height, $image_type) = getimagesize($_FILES["photo"]["tmp_name"]); /* Here gets image type */
$mime_photo = image_type_to_mime_type($image_type); /* This function returns the mime type of the file when the image type got from getimagesize() is passed */
$photo_en = base64_encode($photo_get);
$photo = "data:" . $mime_photo . ";base64," . $photo_en;
从DB获取的数据是data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAGUASgMBIgACEQEDEQH/xAAcAAABBQEBAQAAAAAAAAAAAAAGAQIEBQcDAAj/xAA6EAACAQMDAQUGAwUJAQAAAAABAgMABBEFEiExBhNBUWEHFCJxgZEjMlIVQlOSoSRDVGKCwdHh8Rb/xAAaAQACAwEBAAAAAAAAAAAAAAAEBQECAwAG/8QAJREAAgICAQQCAwEBAAAAAAAAAAECAwQREiExQWEFE0JRcbEi/9oADAMBAAIRAxEAPwCl0m51GzhuovdBL3wwpP7tcoLDVW02a0Fkz9624tg5Fb4lnbJ+WCMf6RXQRovRQPpUbO0Yeuh9pLq4spYtMb+zJtX8Pg/Oh7tQLrSJZ7LVXSOedhI8arkr5fKiX2k+1S5muv2b2XuZrZYHZJ51UAuRx8J8utZVcTT3dxJcXcrzTOdzO5LEnzzVji/0HV7bSNRivGVp9hB2qMVoVx2r0vWrj3s3EcLy8d2zdDWNYJPPTypcgcD58VDWzKytTWjbwAQGUgg9CKXFZ12P7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OeSwmYs1xGoY4OxzyPIkdflTNO1GCG7aCF0lfORhuceWDUue3naNRafhoeSuwED5ZqJdBbTdKxBl6kkAc/Kq7TWgh6OHaFhcTNCRuRiAw8wfCtCtTFpXZ1dwGWXKrjGSegoD7OW7axrW2KRCYB3jkjIyegozngitm726lN3cr+SMdB9KLoahH2L8qfKXFHexmeKWDfkMy5cCrr3yP1/lNVelq6gz3KYlk6L+kVZb18v6UVVqMdMW3Wbl0M8UV0Va8o5r00iQQtLKQFUZOashIk5NRXdlfr8aPZYkx+YYB8aEZLK6t5t9nIVI5C54pdd1O5vNVs0X8jSAqPJR1owSyjlghZcZHn1H1oG+1J78HsMPBlRV9c318+tgqNd1oYh2kMPJDzXU22p6lhr5+7j67R1NGsVkAucKSeOafPEiptxuOKFd68IMVfXWzPdX1e87L26SaUywtKe7c7c+tX/ss7WX9/f8AdauqOk5xFJswcih7tXbJrN4lrESI4XzIw6D0rtDGbd4RbfhiHGwr4YopWJQX7NKfj5XuUn21pf03qSMMAV6g/el2L+k0BaL26EcKwaqrblx+Kg6j1q/HazRiAffl5or7YdxLdgX1S4uDAe716zt8iNu+fyXp96oNR1e4veJGCRZztHT61DeMluAcelQLq0nvJFjJMcPiM8tQztc+jfQfY3w1GH/1CPKXsn2KC61m0lR0MAym4c9f/BWjWcC7QFYECsz0uGSzEYjxhByp/rRVo2sd5cvbv8A2Z8sUPZDmung1yYSi1J/l/oWbo4wSxUADqTiqDV9XjCtFbsHY8ZXwqj1W7e+nIZm7lThUz19arXs9s4kikdXxggHg/Oso1ryEVfH61Kb36JO0Dp1NOAwPWmgsv5lB9VrnL3kilVG0HqSea0Ga6LSEU78t4N0+VLsroFwOOgr2a4nihi8rzTHGHX516vVBD7HSRARnxpkYIm7xTglAPua9XqlNorZFSS3+yVtCcDw4zSUleqSyE8aXGTSV6oLC03Apa9UM4//Z
请有人帮我解决这个问题: - (
答案 0 :(得分:0)
尝试
<img src="<?php echo $studphoto;?>" />
尝试使用
添加标题header('Content-Type: image/jpeg;');