Refer to a file outside the website tree for downloading purposes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ernst

    Refer to a file outside the website tree for downloading purposes

    Hello,

    I'm using Linux Redhat 8.0 (LAMP).
    I have a file tx.zip , that is placed in /tmp.
    Now I want people to be able to download this file without copying it to
    the website tree
    Can I make a reference like http://www.website.com/../../../tmp/tx.zip
    if the root of my website is /var/www/html/Vwebsite ?
    Due to restrictions, I cannot copy the file to /var/www/html/Vwebsite
    Any solutions?

    Thanks Ernst


  • nice.guy.nige

    #2
    Re: Refer to a file outside the website tree for downloading purposes

    While the city slept, Ernst (iceking@xs4all .nl) feverishly typed...
    [color=blue]
    > Hello,
    >
    > I'm using Linux Redhat 8.0 (LAMP).
    > I have a file tx.zip , that is placed in /tmp.
    > Now I want people to be able to download this file without copying it
    > to the website tree
    > Can I make a reference like http://www.website.com/../../../tmp/tx.zip
    > if the root of my website is /var/www/html/Vwebsite ?[/color]

    No. The URI is "relative" to the root of the website folder, not the system.
    [color=blue]
    > Due to restrictions, I cannot copy the file to /var/www/html/Vwebsite
    > Any solutions?[/color]

    Can you make an alias to /tmp in your httpd.conf file? You would be well
    advised to talk to your system admin about this first, though! Possible
    security issues.

    As an alternative, can you upload the file to some other webspace and link
    to that?

    Cheers,
    Nige

    --
    Nigel Moss
    This is the personal website of Nigel Moss - Web and software developer, musician, photographer. It is home to my CV, portfolio, general info and more.

    Mail address not valid. nigel@DOG.nigen et.org.uk, take the DOG. out!
    In the land of the blind, the one-eyed man is very, very busy!


    Comment

    • Guest's Avatar

      #3
      Re: Refer to a file outside the website tree for downloading purposes

      > I'm using Linux Redhat 8.0 (LAMP).[color=blue]
      > I have a file tx.zip , that is placed in /tmp.
      > Now I want people to be able to download this file without copying it to
      > the website tree
      > Can I make a reference like http://www.website.com/../../../tmp/tx.zip
      > if the root of my website is /var/www/html/Vwebsite ?
      > Due to restrictions, I cannot copy the file to /var/www/html/Vwebsite
      > Any solutions?[/color]

      You need two things:

      1 - What To Do: http://www.faqs.org/rfcs/rfc1806.html & http://www.faqs.org/rfcs/rfc2616
      2 - How To Do It: http://us2.php.net/manual/en/function.header.php

      Essentially, your header will look something like the following:

      header("Content-disposition: attachment; filename=/tmp/tx.zip");
      header('Expires : Mon, 26 Nov 1962 00:00:00 GMT');
      header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT");
      header('Pragma: no-cache');

      or for IE :

      header("Content-disposition: attachment; filename=/tmp/tx.zip");
      header('Expires : Mon, 26 Nov 1962 00:00:00 GMT');
      header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT");
      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
      header('Pragma: public');

      _______________ _______________ ______
      Wil Moore III, MCP | Integrations Specialist | Assistant Webmaster

      Comment

      Working...