I’ve got a problem with a downloading script… So I made an uploading script -> it adds the files in a folder called Uploads and inserts id, filename and link into the database.But I can’t find a way to download the uploaded file. Here’s my download script:
[php] <?php
include(‘config.php’);
$dwquery = mysqli_query($db, “SELECT id, filename FROM files”);
$id = intval($_GET['id']);
while ($row = mysqli_fetch_array($dwquery)) {
echo '<a href="download.php?id='.$row['id'].'">'.$row['filename'].'</a><br />';
}
$download = mysqli_query($db, "SELECT link FROM files WHERE id=$id");
$link = mysqli_fetch_array($download);
if($id != '') {
header('Content-disposition: attachment; filename='.$link[0]);
readfile($_SERVER['DOCUMENT_ROOT'] . '/project/' .$link[0]);
}
?>[/php]
It actually downloads the source code of download.php + the text / code that is inside the file I want to download. So it gets the echo:
[php] echo ’ Index / Upload / Download / Logout
';[/php]
And the downloaded file is:
[php] Index / Upload /
Download / Logout
test1.php
test2.txt
and here's the actual code of the file[/php]