Sending a file to user (again)

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

    Sending a file to user (again)

    I asked this a couple of days ago, but got no response. Surely it's not
    difficult?

    I have a file, which my PHP has created, called say, /tmp/fred.txt. I want
    to send that file to the user so a dialog pops up and they get to save
    'fred.txt' (or whatever they name it) on their local disk.

    How do I do that?
  • Randell D.

    #2
    Re: Sending a file to user (again)


    "Derek Fountain" <nomail@hursley .ibm.com> wrote in message
    news:3f065c9e$0 $23108$5a62ac22 @freenews.iinet .net.au...[color=blue]
    > I asked this a couple of days ago, but got no response. Surely it's not
    > difficult?
    >
    > I have a file, which my PHP has created, called say, /tmp/fred.txt. I want
    > to send that file to the user so a dialog pops up and they get to save
    > 'fred.txt' (or whatever they name it) on their local disk.
    >
    > How do I do that?[/color]

    You probably didn't get an answer first time around because your question is
    perhaps more suited to HTML or Javascript newsgroups... It doesn't matter if
    your file was created with PHP or otherwise - Unless you have your web
    browser configured otherwise, a file is a file and will be served to the
    client web browser accordingly...

    However... I believe you can force some web browsers to open up a save as
    box... but it is not guaranteed to work on all browsers.

    One solution though might be to locate the file somewhere in your document
    root (ie where you store your html files) and then just provide a
    hyperlink... that should do it... if not, then try your question at one of
    the other newsgroups that I have suggested for better response...



    Comment

    • Jason Dumler

      #3
      Re: Sending a file to user (again)

      Derek Fountain wrote:[color=blue]
      > I asked this a couple of days ago, but got no response. Surely it's not
      > difficult?
      >
      > I have a file, which my PHP has created, called say, /tmp/fred.txt. I want
      > to send that file to the user so a dialog pops up and they get to save
      > 'fred.txt' (or whatever they name it) on their local disk.
      >
      > How do I do that?[/color]

      I don't think it's too difficult. On the php.net site, do a search for
      the 'header' function in the function search. In the user contributed
      notes, there are several examples of returning a file to a user, where
      they should get the popup winder.

      Some users may still have to right-click on the link and select "Save
      Target As...".

      Jason

      Comment

      Working...