Thursday, 8 August 2013

php - converting csv into array using str_get_csv without physically uploading

php - converting csv into array using str_get_csv without physically
uploading

I'm just trying to upload a csv file and convert it to an array.
I've read on a previous post here that you can use str_getcsv() without
having to physically upload the csv file to the server.
Is this correct or do I have to store the file somewhere first before I
can run str_getcsv() and then delete it afterwards?
Here's my simple code at the moment (I'm using php 5.3):
if (isset($_POST['file_upload'])){
$csv = str_getcsv($_POST['csvfile']);
echo '<pre>';
print_r($csv);
echo '</pre>';
}

No comments:

Post a Comment