[eluser]Gazzhop[/eluser]
view:
Code:
<?php echo form_open_multipart('image_manager/do_upload');?>
<table>
<tr>
<th>Select image you wish to upload</th>
</tr>
<tr>
<td><?php echo form_upload('userfile');?></td>
</tr>
<tr>
<td><?php echo form_submit('submit', 'Upload')?></td>
</tr>
</table>
controller
Code:
<?php
class image_manager extends Controller {
function image_manager()
{
parent::Controller();
$this->load->helper(array('form', 'url'));
}
function index()
{
$this->load->helper('directory');
$map = directory_map(file_url(), TRUE);
$this->load->view('header');
$this->load->view('image_manager_view', array('error' => ' ', 'map'=>$map ));
$this->load->view('footer', array("logged_in"=>TRUE));
}
function do_upload()
{
$config['upload_path'] = 'http://localhost:8888/PDCRARE/images/';
$config['allowed_types'] = 'gif|jpg|png|bmp';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['overwrite'] = TRUE;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('userfile'))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('header');
$this->load->view('image_manager_view', $error);
$this->load->view('footer', array("logged_in"=>TRUE));
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('header');
$this->load->view('image_upload_success', $data);
$this->load->view('footer', array("logged_in"=>TRUE));
}
}
}
/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */
?>
MY_Url_helper
Code:
if ( ! function_exists('file_url'))
{
function file_url($controller = false)
{
if($controller)
return '../CMS_PDCRARE/images';
else
return '../CMS_PDCRARE/images';
}
PROBLEM:
I keep getting path invalid error, but can't see what i'm doing wrong. Sorry if this is simple noob problem.