可能重复:
使用 php 和 mysql 下载文件
嗨,我是 php 和 mysql 的新手。我在我的服务器中上传了一个文件夹,它存储了不同的简历,现在我尝试使用链接下载它们。
<?php
$host="xxxx"; // Host name
$username="xxxx"; // Mysql username
$password="xxxx"; // Mysql password
$db_name="xxxx"// Database name
// Connect to server and select databse.
$conn = mysql_connect("$host", "$username", "$password")or die("cannot
connect");
mysql_select_db("$db_name");
$query="SELECT * FROM userinfo";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"FirstName");
$f2=mysql_result($result,$i,"MiddleName");
$f3=mysql_result($result,$i,"LastName");
$f4=mysql_result($result,$i,"EmailAdd");
$f5=mysql_result($result,$i,"Nationality");
$f6=mysql_result($result,$i,"Street");
$f7=mysql_result($result,$i,"City");
$f8=mysql_result($result,$i,"Region");
$f9=mysql_result($result,$i,"Mobile");
$f10=mysql_result($result,$i,"ExamResult");
$f11=mysql_result($result,$i,"res");
?>
<tr onmousedown="HighLightTR(this,'#A0A0A0 ',' #47433F'); "
onmouseup="p.onload();" >
<td><a href='MemPage.php?selected=<?php echo $f4?>'><?php echo $f4?></td>
<td><?php echo $f1," ",$f2," ",$f3?></a></td>
<td><?php echo $f5?></td>
<td><?php echo $f6,",",$f7,",",$f8?></td>
<td><?php echo $f9?></td>
<td><?php echo $f10?>/27</td>
<td><a href='sms.php?selected=<?php echo $f4 ?>'>Send</td>
<td><a href='http://www.goodfaithjobs.bugs3.com/upload/CRUZSEM2HW.doc'><?
php echo $f11 ?></td>
<?php
$i++;
}
mysql_close($conn);
?>
我能够成功下载文件。因为我指定了一个特定的文件名,但我的问题是如果我想下载一个具有不同文件名的文件怎么办?先感谢您!