0

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

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

4

1 回答 1

0

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

'jar' => 'application/java-archive'
于 2012-08-19T14:24:59.807 回答