如何保护来自非高级用户的远程目录中的可下载文件(在php中?) [英] How to protect downloadable files in a remote directory from non-premium users (in php?)

查看:117
本文介绍了如何保护来自非高级用户的远程目录中的可下载文件(在php中?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立我网站的高级部分,我需要向具有特殊特权的用户(位于mysql数据库中的帐户)直接(在另一台服务器上)授予对远程文件的下载访问权限。我的网站是用php / mysql编码的,所以php解决方案会很棒。

解决方案

将所有下载链接定向到将执行所有凭据检查的php文件。



您可以调用文件download.php



通过cookie传递参数,获取,发布,会话或验证权限的任何方式。 / p>

一旦验证了凭据,就可以发送适当的标头。



如果是图片,标头为 header( Content-type:image / jpeg);



我假设您也拥有这个



一些有用的链接:



MIME类型



PHP标头功能


Im building a "premium" section of my site and Im in a need to give download access to files in a remote directly (on a different server), to users with special privileges (accounts stored in mysql db). My site is coded in php/mysql so a php solution would be great.

解决方案

direct all download links to a php file that'll do all the credential checking.

you can call the file download.php

pass along parameters via cookies, get, post, session, or whichever manner you verify privileges.

once credentials are verified, you can send an appropriate header.

if it's an image, the header would be header("Content-type: image/jpeg");

i'm assuming that you also own this remote server.

some useful links:

MIME types

PHP Header Function

这篇关于如何保护来自非高级用户的远程目录中的可下载文件(在php中?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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