Results 1 to 9 of 9

Thread: Report download

  1. #1

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459

    Report download

    Hello!

    I need to generate online reports from a mysql db. Now i want to have a option which will be...

    to generate a report fro the db...and download it as a text file...how can this be achieved ? I need to download the file without creating it on the server. Means i do not want to first create a text file on server and then download it...i just want to starightly download it...!

    Please help!

    Thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  2. #2
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    AFAIK, you cannot do this. There must be a version of the file on the server that will be served to the browser. You cannot feed something like a buffer to the user.

    The easiest thing would be just to create the file in text file. But each time the page is executed to download the file, have part of your script check for files older than some x time, and delete them. That way your server doesn't fill up and you don't have to write a special app to do this randomly.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  3. #3

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Hi Ober!

    You are wrong at this thing my friend. This is possible and just needs some header manipulation...! I created a script like this and now i forgot how i did it...lemme check it out...and i will post here if i find it...!

    Thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  4. #4
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Ok... no need to be a dick about it. If you already knew how to do it, you shouldn't be posting here in the first place.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  5. #5

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    hi

    i jist forgot it...as i made that with help also...but now i don't even remember how i did it...that is why i posted it...

    thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You need to serve a few headers.
    Content-type: text/plain
    Content-disposition: attachment; report.txt

    I think that's it. Then the output of your PHP script ought to be treated as a text file that gets downloaded.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Thanks! Do i have to do it like this:

    header "Content-type: text/plain
    Content-disposition: attachment; report.txt";
    echo $somevar;

    and this will get downloaded as text file right ?
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    header('Content-type: text/plain');
    header('Content-disposition: attachment; report.txt');

    echo $content;

    That should do it.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Thanks! ;-)
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

Posting Permissions

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



Click Here to Expand Forum to Full Width