I am writing a small app to upload csv files to a folder on a server, then those files will be opened and parsed. But, I'm having trouble pulling these uploaded csv files from their folder where I am saving them. It looks a little like:
//$save_csv->filename is property that i want to open and read
$csvPath = SITE_ROOT.DS.'csv_files'.DS.$save_csv->filename;
public static function getdata($csvFile){
$file_handle = fopen($csvFile, 'r');
while (!feof($file_handle)) {
fgetcsv($file_handle);
$line_of_text[] = fgetcsv($file_handle);
}
fclose($file_handle);
return $line_of_text;
}
$csv = parse_csv::getdata($csvPath);
//This is where i parse the csv file for the info i want
foreach ($csv as $line){
$callNum = $line[2];
$author = $line[5];
$title = $line[6];
$oclcNum = $line[13];
echo sprintf("Title: %s %s OCLC: %s", $title,$author,$oclcNum);
echo "<br />";
}
The parse::getdata
is a method that opens and reads the csv file, But again I can't figure out how to pull the file to be opened. Any help would be fantastic! Thanks!