代码:
$db = mysqli_connect("localhost","root","","photos");
if(isset($_POST['POST'])){
$image = addslashes($_FILES['image']['tmp_name']);
$image_name = addslashes($_FILES['image']['name']);
$image = file_get_contents($image);
$image = base64_encode($image);
$sql = "INSERT INTO imaag ( name ) VALUES ('$image')";
mysqli_query($db,$sql);
}
$res = mysqli_query($db,"SELECT * from imaag");
我得到的图片是:
<div>
<?php
while ($row = mysqli_fetch_array($res)) {
echo '<img
src="data:image/jpeg;base64,"'.base64_encode($row['name']).'/>';
}?>
</div>
检索时,图像被破坏,我不知道图像是否上传。我认为它没有上传。上载部分有一些问题。