views:

57

answers:

1

I created a controller which handles file posts, moves uploaded files to a folder beside the index.php file (not in the application folder, because I want to reach the files directly through http).

The upload works perfectly on Windows based servers but not on Linux. PHP version is still the same on every server, and my local machine.

The code:

    $config['upload_path'] = 'files/pictures/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size'] = '10240';
    $config['encrypt_name'] = true;

    $this->upload->initialize($config);

    if ( ! $this->upload->do_upload('Filedata'))
    {
        //error handling
    }   
    else
    {
        $data = array('upload_data' => $this->upload->data());
        imageResize($data['upload_data']['full_path'],600);
    }

As you can see it's nothing special, it's an ordinary image uploader based on CI. Why do I get an error on Linux?

I tried several ways with the upload path, but none of them work. Folder has chmod 777.

    $config['upload_path'] = './files/pictures/';
    $config['upload_path'] = './files/pictures';
    $config['upload_path'] = 'files/pictures/';
    $config['upload_path'] = 'files/pictures';

None of these work under Linux.

+3  A: 

The temporary directory is missing. The uploaded file is first moved to a temporary directory, before being moved to its destination. The directory name is probably configured somewhere, or you can find it in the documentation. This directory does not exist on the Linux server, and does exist on the Windows server.

Sjoerd
Check if the temporary upload folder exists AND the apache user has write access to it. See @Aircule comment to your question above, it's normally configured by setting upload_tmp_dir in php.ini.
wimvds
This is the problem. Theres no temporary folder.
Nort