download and display links

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • timbratureman@nospam.it

    download and display links

    I have a txt file in my server.
    I have to provide to the user 2 links.
    One link is to download the file and the other one is to display it inside
    the browser.
    Is it possible?
    I made <a href="file.txt" >Download the file</a> but it display it, and it
    does not
    ask me to download it.
    (of course I could download it by clicking the right button,
    but my boss doesn't want that: he wants 2 different links).

  • R. Rajesh Jeba Anbiah

    #2
    Re: download and display links

    timbratureman@n ospam.it wrote:[color=blue]
    > I have a txt file in my server.
    > I have to provide to the user 2 links.
    > One link is to download the file and the other one is to display it[/color]
    inside[color=blue]
    > the browser.
    > Is it possible?[/color]


    Download phpMyAdmin for free. A software tool to bring MySQL to the Web. phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL over the Web. Currently it can create and drop databases, create/drop/alter tables, delete/edit/add columns, execute any SQL statement, manage indexes on columns.


    Search for download in that page. Also, please refer manual
    <http://in2.php.net/header>

    --
    <?php echo 'Just another PHP saint'; ?>
    Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

    Comment

    • John Dunlop

      #3
      Re: download and display links

      An anonymous being wrote:
      [color=blue]
      > I have a txt file in my server.
      > I have to provide to the user 2 links.
      > One link is to download the file and the other one is to display it inside
      > the browser.
      > Is it possible?[/color]

      As Michael said, not reliably. The WWW doesn't work that
      way. You the publisher hold little sway over how a user
      handles your resource.

      The ratified way of suggesting presentational information is
      through the Content-Dispostion header. The disposition type
      'attachment' indicates that the presentation of the resource
      should not be automatic. That's a 'should not', not 'must
      not'; so even software that honours RFC2183 may, under
      certain circumstances, present the resource automatically.

      Besides, note carefully the wording of RFC2183:

      | Bodyparts can be designated `attachment' to indicate that
      | they are separate from the main body of the mail message,
      | and that their display should not be automatic, but
      | contingent upon some further action of the user.



      Nothing there requires that the resource be saved to disk.

      Content-Disposition, though mentioned in sec. 19.5.1, is not
      a part of HTTP1.1, so there's no obligation for browsers to
      support it. To me, it's a step in the wrong direction for
      the web, and I'd dismiss it straight off. Description not
      prescription.

      The other, more common mistake is to claim that the resource
      is something that it isn't by sending a misleading Content-
      Type header. Resources are often sent as application/octet-
      stream, which means 'arbitrary binary data'. If there's a
      more appropriate type, it should be used instead. A plain
      text resource, for example, should be labelled text/plain.
      [color=blue]
      > I made <a href="file.txt" >Download the file</a>[/color]

      That should set alarm bells ringing: verbs are out of place
      in link text. A link itself doesn't do anything; it is
      simply a relationship or connection, as the HTML spec puts
      it. With that in mind, how would you set apart your
      download link now?


      [color=blue]
      > but it display it, and it does not ask me to download it.[/color]

      Because that's how your browser is configured to handle
      resources of that type.
      [color=blue]
      > (of course I could download it by clicking the right button,
      > but my boss doesn't want that: he wants 2 different links).[/color]

      I want a cool breeze and bright sunshine tomorrow, but
      Mother Nature brooks no defiance.

      Slainte! & HAGW!

      --
      Jock

      Comment

      • lunatech

        #4
        Re: download and display links

        timbratureman@n ospam.it wrote:[color=blue]
        > I have a txt file in my server.
        > I have to provide to the user 2 links.
        > One link is to download the file and the other one is to display it[/color]
        inside[color=blue]
        > the browser.
        > Is it possible?[/color]

        Have a look at the PEAR HTTP_Download package
        (http://pear.php.net/manual/en/packag...-download.php). It
        might make your task easier. However as others have pointed out, how
        your content is handled depends on the client's browser not your
        server.

        --

        Raj Shekhar
        System Administrator, programmer and slacker
        home : http://rajshekhar.net
        blog : http://rajshekhar.net/blog/
        work : http://netphotograph.com

        Comment

        Working...