codeigniter上传不在linux上工作

时间:2014-08-14 12:34:59

标签: php linux codeigniter file-upload uploadifive

我正在使用CodeIgniter 2.2.0开发应用程序。在我的应用程序中,用户可以将pdf文件上传到服务器。

我在接口上使用uploadifive.js,我还有一个控制器,首先创建将要存储文件的目录结构。

在我的localhost(W7和Apache)目录上创建一切正常,文件名已加密,依此类推。尝试在我的生产服务器Ubuntu 12上上传文件时出现问题。目录正在创建但没有上传文件。

我已阅读了二十多篇文章,但无法找到解决方案。

这里有几行上传代码,我不是Ubuntu和Linux的专家,所以它必须是一个配置错误的问题。谁知道?

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();
        ...
    }

1 个答案:

答案 0 :(得分:0)

检查文件夹的权限。如果您使用php以编程方式创建文件夹,则可以使用http://php.net/manual/en/function.chmod.php后立即设置权限。

离。

chmod("/path/to/somedir", 0755);