CodeIgniter Forums
Upload csv file straight into array - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Upload csv file straight into array (/thread-11741.html)



Upload csv file straight into array - El Forum - 09-22-2008

[eluser]johnwbaxter[/eluser]
I need to upload a csv file and then use the (single column of data) in an array and then in a query.

How can i do this without first saving the file? I'm sure it's something really simple but i just can't find anything on how i might go about this.

Any ideas anyone?


Upload csv file straight into array - El Forum - 09-22-2008

[eluser]xwero[/eluser]
If you upload the file it's saved as a temp file. You can get the content by using
Code:
$temp_csv = $_FILES['userfile']['tmp_name'];
$content = file_get_contents($temp_csv);
unlink($temp_csv);
What the upload library does additionally is move the file to the destination directory.


Upload csv file straight into array - El Forum - 09-22-2008

[eluser]johnwbaxter[/eluser]
How funny, that really is something i should have known. Thanks xwero, i quite often find silly blanks in my knowledge...