不使用< a>下载文件 [英] Download files without <a>

查看:76
本文介绍了不使用< a>下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在开发一个系统,正如您在其他帖子中看到的那样,允许成员下载文件。当他们下载文件时,我想将用户ID和文件ID与上次下载时间以及下载次数一起存储在表中。


我有SQL for这已经 - 所以没有问题。


不幸的是你不能使用AJAX,因为onclick()中的代码如果有一个URL就不会激活href - URL的默认处理程序将被触发。


所以我的想法很简单。将链接转到更新数据库中的表的php页面,下载文件然后将用户返回到原来的位置。


这引出了我的问题。你如何用PHP下载文件?它可能是一个php文件,一个m3u文件或其他任何东西。


我已经阅读了低级文件函数,但所有这些都可以,据我所知,将文件内容放入局部变量。如何将文件发送到客户端PC并存储他们已经这样做的事实?


任何帮助,建议或指针都非常感谢。


干杯

nathj


PS如何获得为每个帖子设置的电子邮件通知和签名 - 我必须继续编辑我的帖子以设置它?

Hi,

I am working on a system, as you may have seen from my other posts, that allows members to download files. When they download a file I want to store the user ID and the file ID in a table along with the last download time and how many times they have downloaded.

I have the SQL for this already - so no problems there.

Unfortunately you can''t use AJAX for this as the code in the onclick() won''t fire if there is a URL in the href - the default handler for the URL is fired in stead.

So my idea was simple. Have the link go to a php page that updates the table in the database, downloads the file and then returns the user to where they were originally.

This leads me to my question. How do you download the file in PHP? It may a php file, an m3u file or anything for that matter.

I''ve read around the low level file functions but all this will do, as far as I can tell, is put the file contents into a local variable. How can I get the file to the clients PC and store the fact that they have done so?

Any help, suggestions or pointer greatly appreciated.

Cheers
nathj

PS How do you get the email notification and signature to set for every post - I have to keep editing my posts to set it?

推荐答案


如何获得为每个帖子设置的电子邮件通知和签名 - 我必须保留编辑我的帖子来设置它?
How do you get the email notification and signature to set for every post - I have to keep editing my posts to set it?



控制面板>>新订阅的主题>>设置线程的通知复选框,然后在面板底部找到即时电子邮件通知。

Control Panel >> New Subscribed Threads >> Set the notification check box for threads, and bottom of the panel you can find instant email notifications.


嗨nathj


答案实际上是痛苦简单。你需要的是标题(我不记得你的其他帖子,所以我不知道你有多少搞乱了这个)


这应该让你去(希望)


这个文件我们称之为download.php
Hi nathj

The answer is in fact painfully simple. What you need is headers (I don''t remember your other posts so I don''t know how much you have messed with this)

this should get you going (hopefully)

this file we call "download.php"
展开 | 选择 | Wrap | 行号


heh ..忘了说


您可以使用onclick或使用< a href ="">< / a>链接到此文件,无论您放入查询中的文件ID,如http://yoursite.com/path/to/download.php?fid=3245


和你应该得到一个下载查询
heh.. forgot to say

You link to this file, either with onclick or with <a href=""></a>, either way you put the file id in the query like http://yoursite.com/path/to/download.php?fid=3245

and then you should get a download query


这篇关于不使用&lt; a&gt;下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆