How to prevent direct download to file?

Hi all,

I need to make a link to download a file … But only Authorized persons can download it.

The problem is that any body can wirte the direct link for that file and download it… How to prevent that?

Place the file outside of the public part of the web site and use a server side script that checks that the person is authorised to access the file before providing access to it. Because the file is outside of the public folder it will be inaccessible directly and will only be able to be accessed via a server side script that references it and which can include whatever authentication you require before allowiong access.

Of course once they have access to the file you cannot then prevent them sharing it with others.