我有一个小问题
我有一个带有<input type"file">
按钮的HTML表单...我已经为其编写了一些代码,因此它将图像名称保存在MySQL数据库中。但是,如果您没有选择图像,那么数据库中仍然会有一条白线。
这是我的代码:
$query = "SELECT id FROM ncr_input ORDER BY id DESC LIMIT 1";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_row($result);
$ncrnummer = $row[0];
for($i = 0; $i < count($_FILES['attachments']['name']); $i++)
{
$filetmp = $_FILES["attachments"]["tmp_name"][$i];
$filename = $_FILES["attachments"]["name"][$i];
$filepath = "images/".$filename;
move_uploaded_file($filetmp,$filepath);
$querypictureupload = "INSERT INTO file_upload (ncrnummer,filename) VALUES ('$ncrnummer','$filename')";
$result = mysqli_query($conn, $querypictureupload);
}
将图像插入数据库后,我希望它以FPDF格式显示:
$pdf->AddPage();
$query1 = "SELECT filename FROM `file_upload` WHERE ncrnummer = '$ncrnummer'";
$result1 = mysqli_query($conn, $query1);
if ($result1 -> num_rows >0){
while ($row = mysqli_fetch_assoc($result1)) {
$image = $row['filename'];
$pdf->Image("images/".$image,NULL , NULL ,100,85, "");
$pdf->Cell(190, 3, "", 0, 1);
}
}
这是问题所在,因为如果白线上没有文件,FPDF将给出错误代码...