www.webdeveloper.com
Results 1 to 3 of 3

Thread: Hide URL path

Hybrid View

  1. #1
    Join Date
    Nov 2013
    Posts
    1

    Hide URL path

    how would i hide a path to a download for example i have to do this to make people download something but i dont want then to know where i keep all my files

    <a href='mypath/file.zip' download>Download</a>

  2. #2
    Join Date
    Sep 2013
    Posts
    221
    Try out with the below example code:

    $file = 'ASDFGgg.pdf';
    _Download("mypath/file.zip/".$file, $file);

    function _Download($f_location,$f_name){
    header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Length: ' . filesize($f_location));
    header('Content-Disposition: attachment; filename=' . basename($f_name));
    readfile($f_location);
    }

    Hope this helps.
    strad solutionswww.stradsolutions.com

  3. #3
    Join Date
    Nov 2013
    Posts
    3
    Try this:


    <?php
    $dir="/path/to/file/";
    if (isset($_REQUEST["file"])) {
    $file=$dir.$_REQUEST["file"];
    header("Content-type: application/force-download");
    header("Content-Transfer-Encoding: Binary");
    header("Content-length: ".filesize($file));
    header("Content-disposition: attachment; filename=\"".basename($file)."\"");
    readfile("$file");
    } else {
    echo "No file selected";
    }
    ?>

    Hope this code helps:

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles