swf文件未在codeigniter中上传

时间:2013-06-24 10:00:58

标签: php codeigniter file-upload flash

列出的其他文件正在上传,但swf文件没有上传,不支持文件类型错误。

这是我的控制器

function do_upload(){
    $pid=$this->input->post('Page_id');
    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'swf|png|gif|jpg';
    $config['max_size'] = '1048';
    $config['file_name'] =$pid;
    $this->load->library('upload', $config);

    if ( ! $this->upload->do_upload())
    {
        $error = array('error' => $this->upload->display_errors());

        $this->load->view('admin/upload', $error);
    }
    else
    {
        $data = array('upload_data' => $this->upload->data());

        $this->upload_success();
    }
}

2 个答案:

答案 0 :(得分:0)

可能是_file_mime_type函数中的文件上载类的错误 look for more here

答案 1 :(得分:0)

您尚未在do_upload调用中传递字段名称,如

  $config = array(
        'allowed_types' => 'jpg|jpeg|swf|png', // pipe seperated file types
        'upload_path' => './uploads/',// should be the root path
        'max_size' => '1048',
        'file_name' =>$pid
        );
$this->load->library('upload', $config );

if (!$this->upload->do_upload('your_field_name')){  
// like  $this->upload->do_upload($pid)
 $error = array('error' => $this->upload->display_errors());

 }else{
 $swf_data = $this->upload->data(); 
  }

希望它有意义