PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Read contents of CSV file and insert into post body

  1. shayh
    Member

    I am trying to create a form to allow users to upload a CSV file and some PDFs. I need to create links to the PDFs in the post body as well as display the actual content from the CSV file.

    I have looked at gform_after_submission_[form_id] and have the PDF links working fine. My problem is I'm not sure of the best way to get the contents of the CSV file into the post body. Is there a GF function I can use or do I need to use standard PHP? If PHP, does anyone have any sample code I could use as I'm worried about just dumping the contents of the file straight into a post in case there is anything malicious in it (doubtful given the users/environment but you never know).

    Any pointers would be greatly appreciated.

    Thanks,
    Shay

    GF v1.6.11

    Posted 11 years ago on Friday January 11, 2013 | Permalink
  2. You need to use standard PHP to read the CSV and output it into a format you like in your post. I believe the function you want is fgetcsv: http://php.net/manual/en/function.fgetcsv.php

    Posted 11 years ago on Saturday January 12, 2013 | Permalink
  3. shayh
    Member

    Thanks Chris, I actually just need to dump the content as it will be used with the EasyTable plugin, no parsing necessary. I've used standard PHP to read the content of the uploaded file and everything is working now.

    Shay

    Posted 11 years ago on Saturday January 12, 2013 | Permalink
  4. Thanks for the update.

    Posted 11 years ago on Saturday January 12, 2013 | Permalink

This topic has been resolved and has been closed to new replies.