Re: How to change a filename for download (e.g. jpeg, pdf etc.)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2010-01-25 at 10:03 +0000, SED wrote:

> Hi,
> 
> Can anyone point me to tutorials on how to change a filename for each
> download? My goal is to give the downloader a random name for a picture or a
> document, so he will never know what the original filename is.
> 
> Regards,
> Summi
> 
> 
> 
> 


I save the file using the temp filename given to it by PHP during the
upload process. If that's not possible, then some sort of hash (MD5 for
example) of the original file name would suffice. Then, when the user
requests that file, they have to request it with a URL like
file.php?file=hashname

The added benefit of this is that you can verify the user is logged in
or not too. The only problem would be if you were serving media files,
as no plugins I know of send all the correct headers for the media file
request, so your browser would see it as an anonymous request.

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux