[eluser]ellipsis[/eluser]
Hello. I'm trying to create a simple upload form by following the example in the user guide and I keep getting that horrid error. I've tried countless variations on the path ./uploads/files/ and nothing has worked so far. Just to not waste anybody's time here I'm going to answer some of the usual questions. Yes "file_uploads" is set to "on" in php.ini. I'm running XAMPP on Vista x64.
My directory structure is as follows
Quote:C:
|
|-\xampp
| |
|--\htdocs
| |
|---\site
| |
|----\backend
|----\css
|----\frontend
|----\img
|----\js
|----\system
|----\uploads
| |
|-----\files
|----\user_guide
My .htaccess contains the following lines, although it is my understanding that php ignores it so it might actually be of no relevance to the problem
Quote:RewriteEngine on
RewriteCond $1 !^(index\.php|admin\.php|favicon\.ico|css|js|img|uploads|user_guide|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Code:
//controllers/files.php
<?php
class Files extends Controller {
function Files()
{
parent::Controller();
//$this->load->library('session');
$this->load->model('Content_model', "", TRUE);
$this->load->library('upload');
$this->load->library('form_validation');
}
function do_upload()
{
//$upath=.$this->session->'./uploads/files/'.userdata('uid').'/';
$config['upload_path'] = './uploads/files/';
$config['allowed_types'] = 'exe|zip|rar|jar|jpg|jpeg|png|gif';
$config['max_size'] = '0';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
$data['page_title']="Files";
$logdata['username']=$this->session->userdata('username');
$logdata['logged_in']=$this->session->userdata('logged_in');
if($logdata['logged_in']==TRUE)
{
$this->load->vars($logdata);
$data['form_content']=$this->load->view('loggedintop', "", TRUE);
//$db['query']=$this->Content_model->add_files($filefields);
}
else
{
$data['form_content']=$this->load->view('login_form', "", TRUE);
$db['query']=NULL;
}
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$data['page_content']=$this->load->view('files', $error, true);
$this->load->vars($data);
$this->load->view('header');
$this->load->view('content');
$this->load->view('footer');
}
else
{
$error['upload_data']= $this->upload->data();
$data['page_content']=$this->load->view('files', $error, true);
$this->load->vars($data);
$this->load->view('header');
$this->load->view('content');
$this->load->view('footer');
}
}
function index()
{
$data['page_title']="Files";
$logdata['username']=$this->session->userdata('username');
$logdata['logged_in']=$this->session->userdata('logged_in');
if($logdata['logged_in']==TRUE)
{
$this->load->vars($logdata);
$data['form_content']=$this->load->view('loggedintop', "", TRUE);
//$db['query']=$this->Content_model->add_files($filefields);
}
else
{
$data['form_content']=$this->load->view('login_form', "", TRUE);
$db['query']=NULL;
}
$error['error']="do your thing...";
$data['page_content']=$this->load->view('files', $error, true);
$this->load->vars($data);
$this->load->view('header');
$this->load->view('content');
$this->load->view('footer');
}
}
/* End of file files.php */
/* Location: ./frontend/controllers/files.php */
?>
Code:
//views/files.php
<?php echo $error;
echo form_open_multipart('files/do_upload');
echo '<input type="file" name="userfile" size="20" />
<input type="submit" value="upload" />
</form>';
?>
If anyone can spot the problem or point me in the right direction, I'd be really grateful.