[eluser]InsiteFX[/eluser]
pickupman, is correct on the windows permissions.
The error is telling you that the upload library is not loaded!
Try to autoload the library.
InsiteFX
[eluser]adekenny[/eluser]
thanks a lot.
I've autoloaded the "upload" library and the "form" helper as your suggested but it's still not working.
The error message i'm now getting is:
Unable to find a post variable called userfile.
I even tried renaming the form file to "username" and pass it as a post variable ($_FILE['userfile']['name']) to the controller but it kept saying the same thing. I later rename it back to $data as shown in the e-book i'm using but the proble persist.
Please see my view below:
<?php
$this->load->helper('form');
$this->load->helper('url');
echo @$errors;;
echo form_open_multipart('upload/do_upload');
echo form_upload($data);
echo form_submit('mysubmit', 'Submit Post!');
echo form_close();
?>
Also see my controller code:
function do_upload()
{
if(!$this->upload->do_upload($this->userfile))
{
$errors = array('errors' => $this->upload->display_errors());
$data['menu'] = $this->my_menu;
$data['base'] = $this->base;
$data['css'] = $this->css;
$this->load->view('photo_upload_failed', $errors);
}
else
{
$data['myupload'] = array('upload_data' => $this->upload->$this->data());
$data['menu'] = $this->my_menu;
$data['base'] = $this->base;
$data['css'] = $this->css;
$this->load->view('upload_success', $data);
}
}
Thanks for all your help so far......but I still need more HELP to get this solved as i've done all i know to get the do_upload function to see the post variable called "userfile " but it's not just working.
[eluser]adekenny[/eluser]
Please note: I was unable to pass the errors message as a an element of the array ($data) to the view ......So i had to pass only the $errors variable to the view.
I don't know why this is so....
[eluser]adekenny[/eluser]
when i used the code i was getting the error message:
Fatal error: Call to undefined function form_label() in C:\Program Files (x86)\EasyPHP 2.0b1\www\system\application\views\photo_upload.php on line 39
so i changed it back to the previous version.
[eluser]adekenny[/eluser]
Thanks for all your help.....
i've amended it as you advised but the same error message is appearing.
Unable to find a post variable called userfile.
Do i need to change something in my controller or upload library?
class Upload extends Controller
{
var $base;
var $css;
var $my_menu;
var $userfile;
function Upload()
{
parent::Controller();
$this->base = $this->config->item('base_url');
$this->css = $this->config->item('css');
$this->load->library('menu');
$this->my_menu = $this->menu->show_menu();
$this->load->library('upload');
$this->load->library('session');
$this->load->helper('form');
$this->load->helper('url');
}
function do_upload()
{
if(!$this->upload->do_upload($this->userfile))
{
$errors = array('errors' => $this->upload->display_errors());
$data['menu'] = $this->my_menu;
$data['base'] = $this->base;
$data['css'] = $this->css;
$this->load->view('photo_upload_failed', $errors);
}
else
{
$data['myupload'] = array('upload_data' => $this->upload->$this->data());
$data['menu'] = $this->my_menu;
$data['base'] = $this->base;
$data['css'] = $this->css;
$this->load->view('upload_success', $data);
}
}
}
[eluser]adekenny[/eluser]
Hurray!!!!!!
It's working very fine now - i can now upload images to a folder in my root folder.
Many thanks for all your help.
You guys are simply fastastic.......really appreciate your support.
adekenny - Nigeria