Welcome Guest, Not a member yet? Register   Sign In
[solved] File Uploads - path apparently not set correctly
#1

[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?
#2

[eluser]Pascal Kriete[/eluser]
EDIT: Scratch that, I need coffee.
#3

[eluser]Steve Grant[/eluser]
Code:
RewriteEngine On
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
#4

[eluser]Pascal Kriete[/eluser]
Yeah, my first thought was that you might need to add that folder to your rewriteCond, but that is of course total nonsense. Make sure that php has write access to the folder.
#5

[eluser]Steve Grant[/eluser]
It had access to the folder already (I'm developing locally on Windoze), and for some bizarre reason has just decided it's going to work. Very odd!

Cheers anyway.




Theme © iAndrew 2016 - Forum software by © MyBB