0

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

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

在我的本地主机(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();
        ...
    }
4

1 回答 1

0

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

前任。

chmod("/path/to/somedir", 0755); 
于 2014-08-14T13:30:26.723 回答