Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Hide download URL in PHP

Hide download URL in PHP

Scheduled Pinned Locked Moved Web Development
phpcomquestionannouncement
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    Hi, I have policies to documents and I want to put it on a web PHP portal for download to the employee with a password protected access. If the URL for a policy is www.myWeb.com/policies/document1.pdf, I don't want any one to see this url when downloading or when viewing the page source. What's the best way to do it? Thanks, Jassim[^]

    Technology News @ www.JassimRahma.com

    F C M 3 Replies Last reply
    0
    • J Jassim Rahma

      Hi, I have policies to documents and I want to put it on a web PHP portal for download to the employee with a password protected access. If the URL for a policy is www.myWeb.com/policies/document1.pdf, I don't want any one to see this url when downloading or when viewing the page source. What's the best way to do it? Thanks, Jassim[^]

      Technology News @ www.JassimRahma.com

      F Offline
      F Offline
      F ES Sitecore
      wrote on last edited by
      #2

      You can't hide urls from the client. Implement proper security at the webserver level if you want to restrict access.

      1 Reply Last reply
      0
      • J Jassim Rahma

        Hi, I have policies to documents and I want to put it on a web PHP portal for download to the employee with a password protected access. If the URL for a policy is www.myWeb.com/policies/document1.pdf, I don't want any one to see this url when downloading or when viewing the page source. What's the best way to do it? Thanks, Jassim[^]

        Technology News @ www.JassimRahma.com

        C Offline
        C Offline
        Coing_Addict
        wrote on last edited by
        #3

        You could use the HTML5 download attribute like this:

        Click here to download

        1 Reply Last reply
        0
        • J Jassim Rahma

          Hi, I have policies to documents and I want to put it on a web PHP portal for download to the employee with a password protected access. If the URL for a policy is www.myWeb.com/policies/document1.pdf, I don't want any one to see this url when downloading or when viewing the page source. What's the best way to do it? Thanks, Jassim[^]

          Technology News @ www.JassimRahma.com

          M Offline
          M Offline
          Mona sinha
          wrote on last edited by
          #4

          This is how you can hide download url in PHP:

          <?php
          $fakeFileName= "fakeFileName.zip";
          $realFileName = "realFileName.zip";

          $file = "downloadFolder/".$realFileName;
          $fp = fopen($file, 'rb');

          header("Content-Type: application/octet-stream");
          header("Content-Disposition: attachment; filename=$fakeFileName");
          header("Content-Length: " . filesize($file));
          fpassthru($fp);
          ?>

          You can see all steps to hide download url here http://5ss.co/viewtopic.php?f=26&p=3[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups