To read any file, you can use file_get_contents(). If you need more security, for example because the location is user input, you can use the File, which allows you to restrict access to a specific area of the disk.
Once read the data is in a string, and you can use the Format class to convert the CSV file to an array.
You can do something like that for example : $file = Input::file('csv_file'); if ($handle = fopen($file['tmp_name'], 'r')) { while($csv_line = fgetcsv($handle, 0, ';')) { // you have your csv line in $csv_line array } }
and how u save a file in particular folder not the rootdoc folder , i try to change the folder by file config file and seting the //'basedir' => 'assets/uploads/', but it is not working i am getting error as follow
Fuel\Core\OutsideAreaException [ Error ]: File operation not allowed:
thank i got it but , i am working on downloading the file i am using the following code that is File::download(DOCROOT.'assets/uploads/reportfile.csv', 'reportfile.csv'); but for this i am geting the following error ErrorException [ Error ]: Class 'finfo' not found 733 if ( ! $fileinfo = new \finfo(FILEINFO_MIME, \Config::get('file.magic_file', null))) 734 { 735 throw new \InvalidArgumentException('Can not retrieve information about this file.'); 736 } 737 how to solve this ??? Please provide some solution
As of PHP 5.3, the fileinfo extension MUST be present by default in your PHP installation. As such, FuelPHP expects it to be there. If this is your local machine, install it (for Windows, you need to load a DLL which should be pre-installed).
If this is a hoster, complain bitterly, and if they don't fix it, switch hosting companies. As of now, there is no plain PHP workaround.