0

I'm developing an application using CodeIgniter 2.2.0. In my app, users will be able to upload pdf files to the server.

I'm using uploadifive.js on the interface, I also have a controller that first of all creates the directory structure where the file is going to be stored.

Everything works fine on my localhost (W7 and Apache) directory is created, file name is encrypted and so on. The problem occurs when trying to upload a file on my production server, Ubuntu 12. Directories are being created but no file is uploaded.

I have read more than twenty posts but couldn't find a solution.

Here there are several lines of the uploader code, I'm not an expert in Ubuntu nor in Linux, so it must be a misconfiguration issue. Who knows?

if(!empty($_POST['type_folder'])){          

    $upload_file = FCPATH . '/application/files/'.$_POST['number_identification'].'/'.$_POST['type_folder'].'/COD_'.$_POST['id_agreement'].'/'.sha1($_POST['type_folder']."_".$_POST['id_agreement']."_".$_POST['number_identification']).'.pdf';

    if (file_exists($upload_file)) {
        @unlink($upload_file);
    }

    $file_name = sha1($_POST['type_folder']."_".$_POST['id_agreement']."_".$_POST['number_identification']);
    $final_upload_folder = $upload_sub_sub_folder_by_service;

}                   

if ($status != "error")
{
    $config['upload_path'] = $final_upload_folder;          
    $config['allowed_types'] = 'pdf';
    $config['max_size'] = 1024 * 1024 * 4;
    $config['file_name'] = $file_name;          

    $this->load->library('upload', $config);

    if (!$this->upload->do_upload($file_element_name))
    {
        $status = 'error';
        $msg = $this->upload->display_errors('', '');

    }
    else
    {
        //echo "<pre>"; Print_r($this->upload->data()); echo "</pre>";
        $data = $this->upload->data();
        ...
    }
Sam
  • 7,252
  • 16
  • 46
  • 65
mertseger
  • 1
  • 1
  • Are the upload_max_filesize and post_max_size set to large enough to handle the files you are uploading on your Linux server? – JoJo Aug 14 '14 at 13:06
  • Well, I don't think size is a problem. I'm trying to upload a 54KB file. php.ini has: upload_max_filesize = 3M; and post_max_size = 8M; – mertseger Aug 14 '14 at 13:47

1 Answers1

0

Check your folder's permissions. If you create your folders programmatically with php you can set your permissions right after with http://php.net/manual/en/function.chmod.php.

ex.

chmod("/path/to/somedir", 0755); 
St0iK
  • 628
  • 3
  • 10
  • Give it a try with 0777, if it still doesn't work. we are looking at the wrong direction, your issue is something else, i wish i could help you more :/ – St0iK Aug 15 '14 at 09:45