【发布时间】:2014-07-27 00:19:27
【问题描述】:
我有一个运行 2.1.4 的 CI 项目并正在尝试上传 .pdf 文件。
我知道在其他地方有人问过这个问题,但我没有看到任何人确定以下详细信息并尝试更正,但问题仍未得到解决。
主要目标:增加通过 codeigniter do_upload 函数上传 pdf 文件的能力
在其他地方搜索解决方案后,我尝试更新我的 mime.config 文件但没有成功。
var_dump($this->upload->data()) 提供以下输出:
array(14) { ["file_name"]=> string(14) "AL14052701.pdf" ["file_type"]=> string(15) "application/pdf" ["file_path"]=> string(31 ) "/var/www/Inspection/Attachment/" ["full_path"]=> string(45) "/var/www/Inspection/Attachment/AL14052701.pdf" ["raw_name"]=> string(10) "AL14052701 " ["orig_name"]=> string(0) "" ["client_name"]=> string(14) "AL14052701.pdf" ["file_ext"]=> string(4) ".pdf" ["file_size"] => float(313.54) ["is_image"]=> bool(false) ["image_width"]=> string(0) "" ["image_height"]=> string(0) "" ["image_type"]=>字符串(0) "" ["image_size_str"]=> 字符串(0) "" }
然后我检查了我的 mimes.php 文件并确认 pdf 类型包括“file_type”变量中指示的“application/pdf”类型。 . .它的作用:
'pdf' => 数组('application/pdf', 'application/x-download'),
控制器中允许的类型:
$config['allowed_types'] = 'zip|doc|docx|xls|xlsx|ppt|pptx|csv|ods|odt|odp|pdf|rtf|txt|avi|mpeg|mp3|mp4|3gp| gif|jpg|jpeg|png';
php版本
5.3.2-1
我在上传 ods 和 odt 文件时遇到了类似的问题,但能够通过 mimes.php 文件解决这个问题。我还查看了我的 Upload.php
我可以在不使用 codeigniter 时将 pdf 文件上传到同一台服务器,并且能够上传其他文件类型(.doc、.xls、.odt、.ods、.txt 是我尝试过的类型)。我错过了什么?
【问题讨论】:
标签: php codeigniter pdf file-upload codeigniter-upload