-1

I'm a relative novice with this stuff so please pardon my ignorance, but I'm a little lost on how to proceed.

  1. Collect values of text, select, and checkbox inputs on an HTML form.

  2. Store this information as a CSV.

  3. Submit it to a file input field on an external page.

I'm relatively comfortable adding the form values to an array with unShift() and then converting that to a comma separated string with .toString(), .valueOf() or join(). However, I'm at a total loss how to encode that resulting string properly, and even more at a loss as to how to submit that file to an upload input on another page.

I need to do this totally client-side.

Right now I have the provided endpoint URL with the file upload input as the form action, with a post method, but I think I may need to point the form at a script to get this done. Is this totally ass backwards?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    Is it absolutely required to submit the generated CSV as a file input to the external HTML page? Basically you are trying to fake a user file upload without the user actually selected any file? Also what browsers you need to support? – Darin Dimitrov Dec 28 '13 at 17:04
  • SO this works except for the "store this information as a CSV". If you have to do it totally client-side in a web page, you don't have access to the local file system in most browsers afaik – Paul Dec 28 '13 at 17:20
  • Thanks for the response! I need to support back to IE8. And yeah, it's absolutely necessary. Essentially I'm trying to wire up a CRM import, and it only supports CSV files. So yes, I think that cuts to it: faking a user file upload. – Eli Fitch Dec 28 '13 at 17:20
  • You say you may be able to point the form at a script; so does that mean you have access to the server-side? – zungaphobia Dec 28 '13 at 17:21
  • Yeah I can point it at a script, as long as that script ends up sending the data to the right place. Sorry for the flub. FYI I have a design/CSS background. My JS is only okay, and I don't know any PHP. – Eli Fitch Dec 28 '13 at 17:23
  • Having to support IE8 is basically killing all your hopes of achieving that. In modern browsers this can be done using HTML5 [`FormData`](https://developer.mozilla.org/en-US/docs/Web/Guide/Using_FormData_Objects). – Darin Dimitrov Dec 28 '13 at 17:30
  • I know that it's technically possible, because it's already been achieved on http://careers.informatica.com/talentcommunity/subscribe/ . I'm looking at something similar to the top portion of the page, where a user can register their personal information and interest. Probably should have included that earlier, but only just found the example. – Eli Fitch Dec 28 '13 at 17:33
  • I would use PHP, Perl or something server-side to assemble the CSV and send it off to the external server, assuming you don't need the user to be logged into the CRM at the same time. This removes a lot of cross browser issues. http://stackoverflow.com/questions/217424/create-a-csv-file-for-a-user-in-php – zungaphobia Dec 28 '13 at 17:38

1 Answers1

0

I believe what you said "Right now I have the provided endpoint URL" is the URL you need to use directly to POST. You should bias the intermediate html page's form, and use its URL to submit your formatted csv. In any case, it looks like you misunderstood that you have to go through other html page's form's post method's submit. it is not looking reasonable for me. Hope you are not betting with someone to do like this. Please correct me if I have misunderstood.

Siva Tumma
  • 1,695
  • 12
  • 23