Issue
I have uploaded a CSV to codeigniter using a multipart-form, this is the HTML code:
<label for="enterCSV">Enter CSV
<input type="file" name="enterCSV" accept=".csv">
</label>
and this is the php code on the controller:
$csv = $_FILES['enterCSV']['name'];
$file = fopen($csv, r); //open file
while (!feof($file)){ //read till the end of the file
$content = fgetcsv($file); //get content of the file
}
I just want to read the content of the uploaded csv file using my php and manipulate it accordingly.
Solution
you can try this:
$csv = $_FILES['file']['tmp_name'];
$handle = fopen($csv,"r");
while (($row = fgetcsv($handle, 10000, ",")) != FALSE) //get row vales
{
print_r($row); //rows in array
//here you can manipulate the values by accessing the array
}
Answered By - Madhu Answer Checked By - Marie Seifert (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.