SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot DewChugr's Avatar
    Join Date
    Sep 2005
    Location
    Illinois
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help downloading large csv file

    I have a script that is building csv files that I need to be able to download. Right now I am just adding lines one at a time to a var. After that I use the two lines below to download the file, then echo the var with the data.

    header("Content-type="application/vnd.ms-excel"");
    header("Content-Disposition: attachment; filename=data.csv");

    When the files are a few hundred lines long everything works great. But, I have files that are 5-10k long and they never download. I have also written them to a file on the web server and they have worked fine. Although I have not been able to get them downloaded to the local computer unless they are smaller files of a few hundred lines. If I write the file to the server I want to delete it after it is downloaded, I have no need to keep it permanently.

    The lines in the csv file are not all that long, 8 fields, 1 to around 50 characters per field.

    Any ideas where to go with this?

    Thanks

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2006
    Location
    Wigan, Lancashire. UK
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DewChugr View Post
    header("Content-type="application/vnd.ms-excel"");
    header("Content-Disposition: attachment; filename=data.csv");
    Headers aren't actually correct, wrong content type, use of =, bad use of double quotes, and you have a spurious ". You might try using
    Code:
    header('Content-type: text/plain');
    header('Content-Disposition: attachment; filename="data.csv"');

    Quote Originally Posted by DewChugr View Post
    When the files are a few hundred lines long everything works great. But, I have files that are 5-10k long and they never download.
    How long is this taking? Could you be running into a timeout?
    ---
    Development Projects:
    PHPExcel
    PHPPowerPoint

  3. #3
    SitePoint Zealot DewChugr's Avatar
    Join Date
    Sep 2005
    Location
    Illinois
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the tips. After some investigating it turns out my script was running for 2 and a half minutes before the entire file was created (on server).

    Thanks for the help.


Bookmarks

Posting Permissions

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