PHP 代码帮助,尝试使用唯一的 url 下载文件
可能的重复:
强制使用 PHP 下载文件
我目前正在构建一个网站,其中它允许用户上传和下载文件,我正在遵循教程,但正在更改它,我希望此页面显示下载链接,以便用户可以下载文件。这些文件存储在 MYSQL 数据库中。
这是代码,
<?php
include ("Design/header.php");
require ("connect.php");
$itemid = $_GET['album'];
$file = mysql_query ("SELECT * FROM albums WHERE fileid=''");
include ("Design/footer.php");
?>
我只是想不出如何仅为该文件创建下载链接,并使其针对网站上的每个其他文件进行更改。
我将提供更多详细信息,
我对其进行了设置,以便在上传文件时为其提供唯一的 id,并且当在网站上单击该文件时,它将用户带到“viewfile.php?file=”.$row[ '文件id']。"'>"但在 viewfile.php 页面上,我想要它,以便当单击“下载文件”时它会下载正确的文件。
而且代码还没有完成。
Possible Duplicate:
Forcing to download a file using PHP
I am currently building a site where it lets users upload and download files, I am following a tutorial, but am changing it, I want this page to show a download link so that the user can download the file. The files are stored in a MYSQL database.
Here is the code,
<?php
include ("Design/header.php");
require ("connect.php");
$itemid = $_GET['album'];
$file = mysql_query ("SELECT * FROM albums WHERE fileid=''");
include ("Design/footer.php");
?>
I just can't think of how to make a download link just for this file and for it to change for each other file on the site.
I will give more detail,
I have it setup so that when the file is uploaded it is given a unique id, and when the file is click on the site it brings the user to "viewfile.php?file=".$row['fileid']."'>" but on the viewfile.php page I want it so that when "Download File" is click that it downloads the correct file.
Also the code is not finished.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面的代码是从数据库检索数据并将其返回到网页的一般工作流程的示例。
您的一般工作流程是:
一些不错的参考:
The code below is an example of the general workflow for retrieving data from a DB and returning it to a web page.
Your general workflow is:
Some good references for you: