dongpingwu8378 2016-08-25 13:45
浏览 47
已采纳

我无法通过CodeIgniter上传markdown文件

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);
  }
}
  • 写回答

3条回答 默认 最新

  • douanye8442 2016-08-25 14:23
    关注

    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'] = '*';
    

    File Uploading Class

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记