upload_file在我的服务器上无法正常工作

时间:2013-09-14 22:59:04

标签: php codeigniter file-upload

function upload_cover(){
    $config_cover['upload_path'] = 'img/blog/';
    $config_cover['allowed_types'] = 'gif|jpg|png|tif';
    get_instance()->load->library('upload', $config_cover);
    if($this->upload->do_upload('myFile') )
    {
        $upload_data = $this->upload->data();
        $path = 'img/blog/'.$upload_data['file_name'];
        return $path;
    }
}
function upload_file(){
    $config_file['upload_path'] = 'document/blog/';
    $config_file['allowed_types'] = 'doc|docx|pdf|txt|xls|xlsx|ppt|pptx';
    $this->upload->initialize($config_file);
    if ($_FILES['myDoc']) {
        if($this->upload->do_upload('myDoc'))
        {
            $upload_data = $this->upload->data();
            $path = 'document/blog/'.$upload_data['file_name'];
            return $path;
        }
    }
}

这些代码在我的计算机上运行正常,但是当我在我的服务器上部署它时,它只能工作“upload_cover”但是upload_file无法工作我不知道......

1 个答案:

答案 0 :(得分:0)

首先$ _FILES返回一个数组(),请尝试使用此代码编辑密钥以确切知道您收到的内容;

foreach($_FILES as $kt => $val)
{
echo "Key = $kt and val = $val<br>",PHP_EOL;
}

并回复回复,或者结果可能给你答案;

我离开前20分钟。

Hava美好的一天;