I don't know how to set the allowed_types
, and the markdown file suffix is .md
. It always says:
The filetype you are attempting to upload is not allowed.
English is not my native language, so I hope this makes sense. My code:
public function do_upload()
{
$config['upload_path'] = './blog/';
$config['allowed_types'] = ''; //file's tye
$config['max_size'] = 50;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('userfile'))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('houtai_view', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
//$this->load->view('upload_success', $data);
}
}
You just need to allowed_types
in your $config
array
$config['allowed_types'] = 'md';
If you want to allow all kinds of files than you can use *
like:
$config['allowed_types'] = '*';
**Customize File type allow **
$config['allowed_types'] = 'gif|jpg|png';
You can edit APPATH.'config/mimes.php'
file and add 'md' => 'text/plain',
to array.