Reply to Re: how to hide the url of a file for downl load?

Your name:

Reply:


Posted by Hilarion on 07/01/05 12:45

> I'd like to let user download a file but I'd like to hide the url of the
> file.
> I'd like to write something like that:
>
> <a href="download_file.php?id=1123">download file</a>
>
> download_file.php get the file and give it to user.
> BUT...
> ... how can I write download_file.php?
> thank you in advance for your help,



<?php
// download_file.php
$file_locations = array(
1 => 'my/location/file1.zip',
2 => 'my/dislocation/file2.doc',
1123 => 'some/important/file.dbf'
);

Header( 'Location: http://my.server.com/' . $file_locations[ IntVal( $_GET[ 'id' ] ) ] );
?>


You could also read the file contents and return it to client
(giving correct headers first) but this way you'll block download
resuming etc. The main flaw of the solution above is that the
user can get the file location and then use it bypassing
download_file.php.
A good idea would be to get file locations from some database
(not PHP array) and to store somewhere information about
download performed (for download stats).


Hilarion

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация