上传的文件将存储在数据库和文件夹中(文件夹名称:上传).现在我想知道如何从数据库/文件夹创建下载文件.我有两个文件butangDonload.php和download.php.当用户点击"donload"字样时,弹出框将出现并保存文件.
butangDonload.php
donload "; ?>
的download.php
小智.. 13
我已经改变了你的代码,很少修改将很好.这是代码:
butangDonload.php
download "; ?>
的download.php
在这里,您需要显示要下载文件的路径.ie将只提供文件名,但需要提供用于读取该文件的文件路径.因此,它应该被我已经使用您的代码进行测试所取代,并且修改也将起作用.
我已经改变了你的代码,很少修改将很好.这是代码:
butangDonload.php
<?php $file = "logo_ldg.png"; //Let say If I put the file name Bang.png echo "<a href='download1.php?nama=".$file."'>download</a> "; ?>
的download.php
<?php $name= $_GET['nama']; header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header("Content-Disposition: attachment; filename=\"" . basename($name) . "\";"); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($name)); ob_clean(); flush(); readfile("your_file_path/".$name); //showing the path to the server where the file is to be download exit; ?>
在这里,您需要显示要下载文件的路径.ie将只提供文件名,但需要提供用于读取该文件的文件路径.因此,它应该被我已经使用您的代码进行测试所取代,并且修改也将起作用.