PHP upload csv file into array to server -
i trying upload csv file php script, seems first row sent server. tried severals solutions putting q loop while don't while(! feof($handle)){ $data=fgetcsv($handle, 1000, ","); ...}
crashes.
if else me. thanks.
here php script:
<?php $url = 'https://mutalyzer.nl/services/?wsdl'; ?><!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>mutalyzer soap client</title> </head> <body> <h1>mutalyzer soap client</h1> <?php if (isset($_get['data']) && $_get['data']) { echo $_get['data']; $variant = $_get['data']; echo $variant; //$filename = basename($_files['data']['name']); $_files['data']['name']=$_get['data']; $filename = basename( $_files['data']['name']); $handle = fopen($filename, "r"); $data = fgetcsv($handle, 1000, ","); /*while(! feof($handle)){ $data = fgetcsv($handle, 1000, ","); //print_r($data); }*/ //$encripdata = base64_encode($variant); $namechecker=$_get['process']; echo '<h2>result '.htmlentities($variant).'</h2>'; $options = array('features' => soap_single_element_arrays); $client = new soapclient($url, $options); //while(! feof($handle)){ //$data=fgetcsv($handle, 1000, ","); $result = $client->submitbatchjob(array('data' => $data[0], 'process' =>$namechecker)) ->submitbatchjobresult; //print_r(array('data' => $data, 'process' =>$namechecker)); //} print_r($result); } ?> <h2>submit job data file mutalyzer</h2> <form action="" method="get" enctype="multipart/form-data"> <p> input file: </p> <input name="data" type="file" id="data" /> <br/> process : <input type="text" size="10" name="process" id="process" value="namechecker"/> <br/> <input type="submit" name="upload" value="submit" /> </form> </body> </html>
try this, below code works..
<?php // sample_file.csv file contains 35 rows. $row = 1; $csv_array = array(); if (($handle = fopen("c:\users\develop2\downloads\sample_file.csv", "r")) !== false) { while (($data = fgetcsv($handle, 1000, ",")) !== false) { $csv_array[] = $data; } fclose($handle); } // here u can data in csv array fulll rows.. print_r($csv_array); ?>
Comments
Post a Comment