Codeigniter具有不同分机的多个文件

时间:2012-08-19 13:46:36

标签: php codeigniter upload

我正在使用CI_UPLOAD库在Codeigniter中上传屏幕截图和文件。现在截图上传得很好,之后当我上传文件时显示错误。我在谷歌搜索了很多来解决这个问题,但没有得到解决方案。当我在文件中$config['allowed_types']=TRUE工作但我只想要 mp3 / 3gp / mp4 / avi / sis / sisx / jar 文件

$field1 = 'ss';
$config['upload_path'] = IMAGE_UPLOAD_PATH;
$config['allowed_types'] = 'gif|jpg|png|jpeg|pjpeg';
$ext = $this->get_ext($_FILES[$field1]['name']);
$config['file_name'] = date("U")."-screenshot.$ext";;
$this->upload->initialize($config);
if ( ! $this->upload->do_upload($field1)) {
    $error = array('error' => $this->upload->display_errors());
} else {
    $img_data = array('upload_data' => $this->upload->data());
    $data['ss'] = DOMAIN.IMAGE_UPLOAD_PATH.'/'.$img_data['upload_data']['file_name'];
}
///iits working file
//// below code not working
$field2 = 'file';
$config1['upload_path'] = FILE_UPLOAD_PATH;
// i try it with 'mp3|jar' etc
$config1['allowed_types'] = $_FILES[$field2]['type']; 
$ext = $this->get_ext($_FILES[$field2]['name']);
$config1['file_name'] = date("U")."-".$title.".".$ext."";
$config1['max_size'] = 400000;
$this->upload->initialize($config1);
if (!$this->upload->do_upload($field2)) {
    $error = array_merge(array(@$error),array('error' => @$this->upload->display_errors()));
} else {
    $file_data = array('upload_data' => $this->upload->data());
    $data['size'] = $file_data['upload_data']['file_size'];
    $data['file_link'] = DOMAIN.FILE_UPLOAD_PATH.'/'.$file_data['upload_data']['file_name'];
}

显示错误:

The filetype you are attempting to upload is not allowed

现在我厌倦了搜索和解决这个问题

1 个答案:

答案 0 :(得分:0)

您是否尝试过包含/搜索config / mimes.php

'jar' => 'application/java-archive'