I'm sure there are a lot of references out there about reading from text file and display in the browser. but they seem not solving my problem. I'm using CodeIgniter and since I'm new.. I think I missed few things.. even tho I use reference provided by file-uploading codeigniter..(sigh) anyway.. the following are my codes..and I already create upload directory in the server and chmod to 777
application/views/test_page
.....
<form role="form" id="inputForm" action="<?php echo base_url().'upload/do_upload'; ?>" enctype="multipart/form-data">
<div class="form-group">
<label>PLEASE SELECT YOUR INPUT FILE * </label>
<input class="form-control" name="inFile" id="inFile" type="file" required>
</div>
<div class="row">
<div class="col-md-12">
<p align=right><button type="submit" value="upload" form="inputForm" class="btn btn-primary btn-lg">READ FILE</button>
</div>
</div>
</form>
<?php
if(!empty($dataFile))
{
foreach($dataFile as $lines => $value):
print 'No : '.$lines.': '.$value;
endforeach;
}
?>
......
controller/upload as for testing.. I didn't specify the max size/height/width yet since I didn't get the final input file format.. so..
public function do_upload()
{
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'log';
$config['max_size'] = 0;
$config['max_width'] = 0;
$config['max_height'] = 0;
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('inFile'))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('test_page', $error);
}
else
{
$data = array('dataFile' => $this->upload->data());
$this->load->view('test_page', $data);
}
}
The code seems not working. I got an error "You did not select a file to upload." but my infile value shows the input file that I selected. Can anyone help me?.. thanks.