Web input CSV to DB

Soldato
Joined
5 Dec 2003
Posts
2,716
Location
Glasgow
Hi,

I am trying to allow users to enter CSV text or file upload via a web-form which I will then add to a database table using PHP. Can anyone advise the best way to do this?

I think I have a good tutorial to follow for uploading a file using jQuery. I have done some AJAX and get/post forms but not sure how I would do with a big long CSV string?

Also, is it easy enough to parse the CSV in PHP or is there a plugin worth getting? It's not a complicated CSV, just key-value pairs really.
 
Soldato
OP
Joined
5 Dec 2003
Posts
2,716
Location
Glasgow
Yeah it will just be a textarea control. I just am used to doing forms where it would be field and then value so I wasn't sure how POSTing something with lots of commas etc. would go through but I guess it will be okay.

Thanks!
 
Soldato
OP
Joined
5 Dec 2003
Posts
2,716
Location
Glasgow
Yeah I will have a file upload option as well.

I have tried implementing this today, I didn't use fgetcsv as it wanted a filehandle. But if I used another str_getcsv. So it picks up the commas fine but not new lines, I am not sure how these are sent in the POST? I didn't have Firebug or anything to take a look at. So I tried using explode("\r\n", $POST... but didn't seem to catch them either.
 
Back
Top Bottom