Click here to Skip to main content
14,452,932 members
Rate this:
Please Sign up or sign in to vote.
See more:
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.
 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();
// 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");

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
Updated 20-Dec-12 2:33am
Zoltán Zörgő 20-Dec-12 7:04am
You get the error when the downloader is trying to start a second thread, or at the first thread start (try disabling the parallel download)? Have you checked if the http request started by the downloader contains the same information as the request initiated by the browser?
Er. Tushar Srivastava 20-Dec-12 7:11am
Okay! Let me check these things Thank You..... Yet even though the case is that if the problem is arising in my IDM which actually works perfect for all the files on internet then the same problem will arise if some other user will try to download the file from my website.... assume it not as IDM error yet the website scripting error or something. Thank you....
Zoltán Zörgő 20-Dec-12 16:18pm
No, I am not assuming that this is an error in the downloader. But let's do it in the other direction:
- can happen, that the downloader can't get your session cookie, or something else your server might need, thus if the requests do not contain the same data, that can guide you what to fix on your side
- since your content is not static, the web server nor PHP by itself won't be able to support multipart downloads (you can do this tough by handling other http request fields) - so, your response header could misguide the downloader. I suggest you try sending an Accept-Ranges: none in the header. Check rfc2616 for range related things.
Er. Tushar Srivastava 21-Dec-12 5:44am
Thank you Sir... hope that it may help me... I will be trying it right now... :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100