CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge -> Tips & Solutions

 Hide and protect your downloadable items

Print topic Send  topic

Author Message
Markie


Posts: 251
Posted: 10/15/2008, 7:23 AM

Let's say I store my downloadable items in the folder "downloadthis". This is what I do to protect the contents of this folder and also 'anonymize' the URL:

1. I make a textfile (named .htaccess) with this contents:

#

deny from all

#

and I put it in the folder where my downloadable items reside (for example, "downloadthis").

2. I enable the mod_rewrite module (Apache webserver) and make a new textfile (also named .htaccess) with this contents:

#

DirectoryIndex getfile.php index.php

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^download/(.*) getfile.php?file=$1&filename=$1 [nc]

#

I store this .htaccess file in the rootfolder of my website

3. I make a php file (named getfile.php) with this contents:

<?php
$file = $_GET['file'];
$filename = $_GET['filename'];
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header ("Content-disposition: attachment; filename=".$filename.";");
// Length required for Internet Explorer
header("Content-Length: ".@urldecode(@filesize($file)));
@readfile($file);
?>

4. I add a link to a downloadable item on my site:

http://www.mysite.com/download/downloadableitem.jpg

You see, the exact location of downloadableitem.jpg is rather hidden, cool ain't it ?

Markie
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.