这个问题在这里已经有答案了:
php display image blob from mysql[duplicate](3个答案)
如何从mysql数据库中检索图像并在html标签中显示(5个答案)
两年前关门了。
我有一个脚本,可以将文件插入数据库blob类型。我可以看到文件名,但我不能打开/下载文件,因为你可以看到我尝试了回声,但似乎它没有开始下载文件
<form method="post" enctype="multipart/form-data" >
<input type="file" name="myfile"/>
<button name="btns"> Incarca Schita </button>
</form>
<?php
$dbh = new PDO("mysql:host=localhost;dbname=highmob_comenzi", "highmob", "PW");
if(isset($_POST['btns'])){
$name = $_FILES['myfile']['name'];
$type = $_FILES['myfile']['type'];
$data = file_get_contents($_FILES['myfile']['tmp_name']);
$stmt = $dbh->prepare("UPDATE players SET data='$myfile', name='$name', mime='$type' WHERE id='$id'");
$stmt->bindParam(1,$name);
$stmt->bindParam(2,$type);
$stmt->bindParam(3,$data);
$stmt->execute();
}
?>
<?php
$stat = $dbh->prepare("select * from players where id='$id'");
$stat->execute();
while($row = $stat->fetch()){
echo "<a href='".$row['data']."'>".$row['name']."</a>
";
}
?>
暂无答案!
目前还没有任何答案,快来回答吧!