Answer the question
In order to leave comments, you need to log in
How to download a file from a web server using a direct link in PHP?
Available:
OS - Windows
Web server - IIS 7
DB MySql
Links to files are written to the DB, like - D:\dir\one_more_dir\files\file.txt
The files are on the D:\ drive, IIS is on the C:\ drive.
Script:
$res = mysql_query("SELECT link FROM files");
$row = mysql_fetch_array($res);
do {
print "<a href='index.php?file=".$row['link']."'>Download</a></td>";
}
while($row = mysql_fetch_array($res));
if (isset($_GET['file'])) {
$file = $_GET['file'];
if (file_exists($file)) {
print "OK";
}
}
Answer the question
In order to leave comments, you need to log in
Try the same thing from the IIS folder, then from the C: drive folder, then from other places. Most likely something with the rights (IIS can work as LocalServices) or with the passed path itself.
I think the best solution is to keep the files on the server, because as far as I remember, php can't do that
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question