newbie |
[eluser]Unknown[/eluser]
hii all,, i'am a newbie with codeigniter i'want upload data file .csv, can you help me please with a example file?
[eluser]Starman[/eluser]
Are you just trying to upload the file to a folder? Or do you plan to upload the file, then import it into a mysql db? This may be a silly question, but have you read up on the "File Uploading Class" in the user guide? If not, you should check it out, its a short read with code examples. Here's a link to the page: http://ellislab.com/codeigniter/user-gui...ading.html I'm a bit tied up at the moment, but once I get sometime later, I'll tweak one of my upload controllers to suit you needs & paste the code here if you like. Somebody will probably beat me to it though, because the people here are normally very helpful from what I've seen.
[eluser]Unknown[/eluser]
@denis: upload and input into my db, , @starman : if i just to upload file to a folder,i was succesfull yups,i try to import it and put into a mysql db,, wow,,apparently it seems interesting here's my code function importCsv() { $config['upload_path'] = './tmp/'; $config['allowed_types'] = 'csv'; $config['max_size'] = '2000'; $config['remove_spaces'] = true; $config['overwrite'] = true; $this->load->library('upload', $config); $this->load->library('CSVreader'); // <-- i get some code library from googling if(!$this->upload->do_upload('csvfile')){ $this->upload->display_errors(); exit(); // echo "bisa"; }else{ $this->upload->display_errors(); //echo "kagak"; } $csv = $this->upload->data(); $path = $csv['full_path']; //$r = $this->csvreader->parseFile($path); // <--- here's the problem echo '<pre>'; print_r($path); echo '</pre>'; above coding is my experiment, but I want to break it into several arrays the result of foreach example: foreach($r as $row){ // <-- $r is the paseFile $additional_data = array( 'member_id'=>$row->member_id, 'firstname'=>$row->firstname, 'lastname'=>$row->lastname, 'description'=>$row->desc, 'soal'=>row->soal, ); $this->akademik_model->insertSoal($additional_data); } mmm how the hell? convert csv to array and put to my db? thanks before All |
Welcome Guest, Not a member yet? Register Sign In |