【问题标题】:Can I upload .c or .cpp file using CodeIgniter?我可以使用 CodeIgniter 上传 .c 或 .cpp 文件吗?
【发布时间】:2012-10-22 15:05:17
【问题描述】:

我想上传一个 .c 文件。我正在使用 CodeIgniter。我正在使用的代码适用于 .pdf,但每当我尝试上传 .c 文件时,它都会显示“不允许您尝试上传的文件类型。”。

我的代码如下:

$config = array
(
    'upload_path' => './solutions',
    'allowed_types' => 'c',
    'file_name' => $file_name,
    'file_size' => 1000,
    'remove_spaces' => 'true'
);
$this->upload->initialize($config);

当我以允许的类型编写 pdf 时,它可以工作,但在 C 的情况下则不行。

【问题讨论】:

    标签: php codeigniter file-upload


    【解决方案1】:

    在 allowed_types 中,您需要具有 MIME 类型。

    对于“text/plain”的 c 源文件,因为没有“c”MIME 类型。

    http://en.wikipedia.org/wiki/Internet_media_type

    【讨论】:

    • 也看看 config/mimes.php :)
    • 非常感谢。我已经成功上传了一个c文件。 :) :) :D
    猜你喜欢
    • 2020-05-04
    • 2015-07-27
    • 2012-05-24
    • 2013-12-24
    • 1970-01-01
    • 2013-12-05
    • 2020-04-21
    • 2011-08-14
    • 2017-07-28
    相关资源
    最近更新 更多