简体   繁体   English

FPDF无法创建图像

[英]FPDF can't create image

I select an image from a database table and save it in a variable: 我从数据库表中选择一个图像并将其保存在变量中:

(Connection already established) (连接已建立)

require('fpdf.php');

$sql = "SELECT * FROM users WHERE ID=1";
$result = $dbConnection->query($sql);
$row = $result->fetch_assoc();

$id = $row['ID'];               
$image = $row['Profile'];


//Encode the image selected
$img = 'data://text/plain;base64,' . base64_encode($image);

//FPDF STUFF
$pdf = new FPDF();
$pdf->AddPage();
$pdf->Image($img,10,10,39,'jpg');
$pdf->Cell(0,8,$id,0,1);

Then i get this error Message when trying to run the php script: 然后我在尝试运行php脚本时收到此错误消息

Fatal error: Uncaught Exception: FPDF error: Image file has no extension and no type was specified: data://text/plain;base64, [BINARY IMAGE DATA] in C:\\xampp\\htdocs\\fpdf.php on line 271 致命错误:未被捕获的异常:FPDF错误:图像文件没有扩展名且未指定类型:data:// text / plain; base64,第271行上C:\\ xampp \\ htdocs \\ fpdf.php中的[BINARY IMAGE DATA]

So what am i supposed to do? 那我该怎么办? Or what did i do wrong? 还是我做错了什么? (Code Snippet was found on GitHub) (在GitHub上找到了代码段)

You're misplacing the type parameter. 您正在放错类型参数。

$pdf->Image($img,10,10,39,HEIGHT_HERE,'jpg');

see documentation 请参阅文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM