这是图像的回显输出我将图像作为 blob 存储在数据库中,如下面的代码所示 <?php // extract form values if(isset($_POST['submit'])) { $empnum = $_POST['emp_num']; $lastname = $_POST['emp_lname']; $firstname = $_POST['emp_fname']; $initial = $_POST['emp_initial']; $job = $_POST['job']; $username = $_POST['emp_usr']; $password = $_POST['emp_pass']; $emp_bdate = $_POST['emp_bdate']; $check = getimagesize($_FILES["image"]["tmp_name"]); if($check !== false){ $image = $_FILES['image']['tmp_name']; $imgContent = addslashes(file_get_contents($image));员工详细信息的插入// build query $qry = "INSERT INTO employee VALUES(" . "'$empnum','$lastname','$firstname'," . "'$initial','$job'," . "'$username',PASSWORD('$password'),' $emp_bdate',' $imgContent')"; } // execute query $added = mysqli_query($dbconn,$qry);这是为了检查是否有任何错误 // report results if(trim($added) != "") echo "Record added successfully." . "<br>"; else { echo "ERROR: Record could not be added<br>" . mysqli_error($dbconn); } // close connection mysqli_close($dbconn); } ?>虽然没有显示图像,但我正在输出如下图像 $imageData =base64_encode($line['image']); echo "<img src='data:image/jpeg;base64,$imageData' height='200' width='250' alt=''>'" [1]: https://i.stack.imgur.com/8HsOH.png
2 回答
- 2 回答
- 0 关注
- 272 浏览
添加回答
举报
0/150
提交
取消