Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
how i get a CSV file downloable with headers?
  • I take a table in a hidden field, so i want to retrieve that fiel as a CSV, obviusly with the headers but the problem is that when i return the headers i just get an empty file so my question is how can i do to pass the variable with the info in order to download the CSV?
  • I'm a bit confused to what you exactly want to do, I read a lot of actions in your question.

    Start: you have a table with rows of data.
    -- some interaction in between --
    Final result: you want to download this table as a CSV file.

    Correct? So you want to know how you convert a table into CSV, and how you download the resulting CSV?
  • i get my table with an variable with Input::post(), the problem is that i dont know how make that variable info downloable  cause i dont see the way i can return a response with the headers and this info, i tried but it just gives me an empty CSV file
  • What is in that variable? You can't stick a "table" in a variable? The name of the table? And how big is this table? Any special requirements to the format of the CSV file?
  • thanks for your reply but i already fixed it, the thing is that i use a jquery pluging to get the table in an input, and the way i used to get a downloable CSV of that data was this:

    $headers = array (
    'Content-Type'     => 'text/csv; charset=utf-8',
    'Pragma'            => 'no-cache',
    'content-disposition' => "attachment; filename='clicks.csv'"
    );
    $csv = Input::post('csv_text');
    $response = new Response($csv, 200, $headers);
    return $response;
  • That is an option. File::download() would have been another one.

    I just had trouble understanding what you wanted, and this doesn't really help. I have data in CSV format, and I past that into a form, so I can get the same data returned to me as a file when I submit the form?
    Why not just open the file locally, paste the data in, and save? Still puzzled about the use-case... ;-)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion