[eluser]ProImage Web[/eluser]
Finished Controller Function
Code:
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'css';;
$config['max_size'] = '1024';
$config['max_width'] = '1280';
$config['max_height'] = '1024';
$config['max_filename'] = '60';
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
//validate
$this->_set_rules();
//show errors
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->themes->view('home', $error);
} else {
//do upload and parse the file
$filename = $this->upload->file_name;
$file_path = './uploads/';
$write_path ='./uploads/data.php';
$orig_name = $this->upload->orig_name;
$start_string = $this->input->post('start_string');
$stop_string = $this->input->post('stop_string');
//read our file and place lines into an arry for reading
$data1 = read_file($file_path.$filename);
$lines = explode("\n", $data1);
//for each line to read do something
$newline = "\n";
$between = "";
foreach ($lines as $line){
$deduct = strlen($start_string);
$full = substr(substr($line, strpos($line, $start_string), strpos($line, $stop_string) - strpos($line, $start_string)), $deduct);
//if something to output perform action else skip
if ($full){
$between .= $full.$newline;
write_file($write_path, $between, 'r+');
}
}
//delete our source file so not to clutter the server
unlink($file_path.$filename);
}
//read the written file and output the data to the view
$data['results'] = read_file($write_path);
$this->themes->view('results', $data);
}