Jump to content

[SOLVED] Uploading CSV file to MySQL database


jeeves245

Recommended Posts

Hey guys, another question :)

 

I currently use this code to open a CSV file (from a folder on the server) and insert it into a database:

 

$file_handle = fopen("file.csv", "rb");

while (!feof($file_handle) ) {
$line_of_text = fgets($file_handle);
$parts = explode(',', $line_of_text);

 

Then the SQL querys come after that.

 

How hard would it be to modify that to upload the CSV file using a form? (I.e. browse to the file on the computer and submit it).

I don't want the whole file just to be chucked in the database though, I need the code to save pieces into an array like the above code does.

 

I've done a lot of research on Google but most pre-made scripts are too complex for my needs.

 

Would this be hard to do?

 

Thanks in advance.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.