SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    12
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    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?

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    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.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •