[eluser]BrianDHall[/eluser]
OK, here you go. Fully working code!
Change upload path to your folder, make sure permissions are correct (755 I think works) and ensure it is permitted for access in your .htaccess file.
Function for your controller
Code:
function upload_file()
{
$config = array(
'upload_path' => './uploads',
'allowed_types' => 'uvc',
'overwrite' => false,
'encrypt_name' => true,
'remove_spaces' => true,
'max_size' => 500);
$this->load->library('upload', $config);
if ($this->input->post('upload'))
{
$result = $this->upload->do_upload();
$data = $this->upload->data();
if ($result)
{
echo "It worked!\n";
var_dump($data);
}
}
$this->content = $this->load->view('fileuploadform');
}
View:
Code:
<h3>Upload an Image</h3>
<?=form_open_multipart('upload_file')?>
<?=$this->upload->display_errors()?>
<?=form_upload('userfile')?>
<?=form_submit('upload', 'Upload')?>
<?=form_close()?>
Open mimes.php in config folder, should have something like:
Code:
$mimes = array( 'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'uvc' => 'text/plain',
...
If you still get file unallowed backup your mimes file and replace whole file with:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| MIME TYPES
| -------------------------------------------------------------------
| This file contains an array of mime types. It is used by the
| Upload class to help identify allowed file types.
|
*/
$mimes = array('uvc' => 'text/plain');
/* End of file mimes.php */
/* Location: ./system/application/config/mimes.php */
This works great on my system, so if not working be sure to put this in a fresh controller, perhaps on a fresh version of CI - because this should work just fine!
Let me know if you get it working!