[eluser]Steve Grant[/eluser]
Hi, noob here.
I'm trying to allow file uploads which also tie into an INSERT into my MySQL database, but at the moment I can't actually get the file uploads to work.
I'm getting the "The upload path does not appear to be valid" (twice) error - I've spotted a thread that solves the double-printing of that - but I've followed the instructions in the user guide pretty much to the letter:
Code:
function add()
{
$config['upload_path'] = './uploads/'; # should point to <root>/uploads
$config['allowed_types'] = 'gif|jpg|png';
$config['overwrite'] = false;
$config['max_size'] = '1024'; # limit to 1MB
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['encrypt_name'] = true;
$config['remove_spaces'] = true;
$this->load->library('upload', $config);
if($this->input->post('surname'))
{
if($this->upload->do_upload('photo')) # field name on form is 'photo'
{
$uploadData = $this->upload->data();
$fileName = $uploadData['file_name'];
}
else
{
$fileName = 'NULL';
}
$data['error'] = $this->upload->display_errors();
$data['success'] = $this->PlayerModel->add_player(... , $fileName, ...); # extra params removed to make it easier to read
}
}
Every attempt to post a valid file gives me the upload path error message.
I have the following directory structure:
root
|-- css
|-- images
|-- js
|-- uploads
|-- system
.htaccess
index.php
So surely the upload_path of "./uploads/" should be correct in pointing to the uploads directory as shown in that directory structure...
Any ideas?