Brian Dunning wrote:
I have a system where I'm trying to facilitate a process for customers to upload data to me (basically a list of people), and have it go into a database. I can give them certain parameters, like it has to be a CSV file, delimited in such a way, etc. but can't ask much more of them than that, since people are largely stupid. :)
For CSV, it's as simple as explode() the data by "\n" (perhaps strip out any "\r" before you start) and then explode() by ",". Depending on the software they're using, you might also need to remove any delimiters on each field of data, such as quote marks (").
If other file formats are possible as well as CSV, you might like to look at the PEAR "File Formats" packages[1].
And then there would be the usual multipart form upload where they select their file and send it up. I'd need to import it into MySQL.
Again, just receive the file data, do some checking to make sure it's of the expected type, run mysql_real_escape_string() on it, and insert it into a MySQL table.
You could use a PEAR package such as HTTP_Upload[2] to help with the uploading bit, and perhaps a database abstraction layer such as PEAR's DB package[3] for the MySQL bit.
Before I sit down and start coding this thing from scratch, does anyone know if there is something similar out there already that could give me a head start?
HTH Jasper [1] http://pear.php.net/packages.php?catpid=33&catname=File%20Formats [2] http://pear.php.net/package/HTTP_Upload [3] http://pear.php.net/package/DB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php