Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    I have two requests:

    1) I know a downloading script can be made to use php to get the file so that the user does not know the complete address of the file that they are downloading... can someone give me a link to this script?

    2) Can you hide the location somehow that it is downloading from? ex. the windows explore download window says: Downloading ****.zip from Site.com. I want it to not show the Site.com or replace it with something else of my choice... is this possible? And how?
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  2.  

  3. #2
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    Assuming you have the location of the files in a table 'downloads', with fields 'id', 'location', and 'description', you need a script to list the files
    PHP Code:
    <?php
    // file download_index.php
    mysql_connect("host""user""password");
    mysql_select_db("site_db")
    $sql "select id,description from downloads";
    $result mysql_query($sql);
    while ( 
    $row mysql_fetch_array($result) ) {
      echo 
    "<a href=\"download_file.php?id=".$row['id']."\">".$row['description']."</a><br>";
    }
    ?>
    Then the actual download...
    PHP Code:
    <?php
    // file download_file.php
    if (!isset($id)) {
      echo 
    "No file selected";
      die();
    }
    mysql_connect("host""user""password");
    mysql_select_db("site_db")
    $sql "select id,location from downloads where id=$id";
    $result mysql_query($sql);
    if (!
    $result) die();
    $row mysql_fetch_array($result);
    //Do some fancy header stuff... (from php readfile() reference)
    $user_agent strtolower ($_SERVER["HTTP_USER_AGENT"]);
    header"Content-type: application/force-download" );
    if ((
    is_integer (strpos($user_agent"msie"))) && (is_integer (strpos($user_agent"win")))) {
      
    header"Content-Disposition: filename=".basename($row['location']));
    } else {
      
    header"Content-Disposition: attachment; filename=".basename($row['location']));
    }
    header"Content-Description: File Transfert");
    //readfile sends the file straight to output
    @readfile($row['location']);
    ?>
    Untested

    You could probably get rid of all the database stuff if you protected the downloads directory with a .htaccess file. You could then send the location straight to the download_file.php script, letting users know where the file is, but they would be unable to access it directly.
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)

  4. #3
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    Oh, and as for question 2, the browser has to get the file from somewhere, so it has to know either the domain name (www.domain.com) or the ip address (1.2.3.4). There might be a tricky way to stop IE from displaying it, but I doubt it.
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)

  5. #4
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Hi.

    I haven't tried to completely hide the location of my downloadable files, but at least I can hide the exact path by using the following code
    (this is BTW for jpeg-images)
    PHP Code:
    <?
    $fp 
    fopen("../folder/subfolder/$_POST[file]","r");
    $buff fread($fp,1500000);
    Header("Content-Type: image/jpg");
    Header"Content-Disposition: attachment; filename=$_POST[file]");
    echo 
    $buff;
    ?>
    The referrer file sets the variable $file to whatever file the visitor wants to download. The download dialog box won't list the full path like mydomain.com/folder/subfolder/filename.jpg, but just mydomain.com


    If you're rerouting from mydomain.com to download.com where you keep your downloadable files, its apparently possible to hide download.com and show mydomain.com instead, by using this code which was posted in another forum.
    S. Rosland


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:01 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com