codeigniter上传不工作在linux

codeigniter上传不工作在linux

本文介绍了codeigniter上传不工作在linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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.

在我的localhost(W7和Apache)目录中创建一切正常,文件名加密,等等。尝试在我的生产服务器(Ubuntu 12)上上传文件时会出现问题。正在创建目录,但不会上传任何文件。

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.

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

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


推荐答案

检查您的文件夹的权限。如果您使用PHP以编程方式创建文件夹,则可以立即使用。

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);

这篇关于codeigniter上传不工作在linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 20:18