文件上传在我的服务器上无法正常工作 [英] File upload not working properly on my server

查看:155
本文介绍了文件上传在我的服务器上无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    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'] = 'img/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 。为什么?

This code is working properly on my computer but when I deploy it on my server only upload_cover works, and not upload_file. Why?

推荐答案

 function upload_file(){
        $config_file['upload_path'] = 'img/blog/';
        $config_file['allowed_types'] = 'doc|docx|pdf|txt|xls|xlsx|ppt|pptx';

        get_instance()->load->library('upload', $config_file);// try to add this
        $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;
            }
        }
    }

...

这篇关于文件上传在我的服务器上无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆