tags:

views:

787

answers:

1

I need to let users pick a CSV or XLS file from their filesystem and press Submit and have PHP open it, look at it, decide if it is valid and then put the data in MySQL.

I am stuck on how the server gets the file they pick from their desktop?

Do I have to upload the file they pick to a temp directory?

Can I just take a copy and check it in memory?

Advice would be appreciated!

+3  A: 

Read Handling File Uploads in the PHP documents. That will cover how to get it to the server. You do upload the file using a POST to a temporary directory on the server (handled fairly seamlessly for you) and then you just take the filename that it gives you and open that file.

Rob Prouse
Rob, thanks, I thought it had to be uploaded, but was hoping I could do it in memory.
the difference being?
hop
When the file is uploaded, it'll end up being written in a temporary directory on the server's disk at first, but from there, you can open it in memory and do your things without necessarily moving it elsewhere on your server if that's what you want.
lpfavreau