通过IDM提供下载,而不使用PHP显示文件的URL [英] Provide download through IDM without revealing the file's url using PHP

查看:558
本文介绍了通过IDM提供下载,而不使用PHP显示文件的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Friends,

我正在用PHP开发一个网站。我陷入困境,现在我来这里寻求帮助。我正在尝试保护存储文件的URL,并且不希望我的用户获得相同的链接。我试过这样的东西,实际上工作正常。

Hello Friends,
I am developing a website in PHP. I am stuck at a point and now I am here to ask for help. I am trying to secure the url where my files are stored and don''t want my users to get the link of the same. I tried with something like this which actually is working fine.

<?php
 session_start();
 if(!isset($_SESSION['ID']) && isset($_SESSION['ID_old']))
 {
// This is just a simple test for user coming here from the correct path
// and not directly
  session_id($_SESSION['ID_old']);
  $_SESSION['ID'] = session_id();
  unset($_SESSION['ID_old']);
// This is the main code that I want to show you guys
  $file = urldecode($_GET['file']);
  header("Content-disposition: attachment; filename=".$file);
  header("Content-type: ".mime_content_type("filestore/".$file));
  header("Content-length: ".filesize("filestore/".$file));
  header("Content-Transfer-Encoding: binary");
  
  readfile("filestore/".$file);
 }





这是一个提供文件下载的功能,而不会向普通用户显示文件的地址(不能说是高级用户,即黑客)。

然而问题是这种方法似乎不适用于IDM并拒绝下载链接...

错误:某些网站不允许下载文件两次。



请帮我解决这个问题....非常感谢。



随着问候

Tushar Srivastava



This is the function that provides the download of the file without revealing the address of the file atleast to normal user (can''t say for advanced users i.e. hackers).
Yet the problem is that this method seems not to be working with IDM and it refuses the download link...
Error : Some sites do not allow downloading of files twice.

Kindly help me with the problem.... Thank you very much.

With Regards
Tushar Srivastava

推荐答案

_SESSION [' ID'])&& isset(
_SESSION['ID']) && isset(


_SESSION [' ID_old']))
{
// 这只是一个简单的测试,用户来自正确的路径
// 而不是直接
session_id(
_SESSION['ID_old'])) { // This is just a simple test for user coming here from the correct path // and not directly session_id(


_SESSION [' ID_old']);
_SESSION['ID_old']);


这篇关于通过IDM提供下载,而不使用PHP显示文件的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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