在过去的一个小时里,我一直在搜索 Code Igniter 论坛,试图弄清楚这一点:
我正在使用 Code Igniter 为 Web 应用程序编写文件上传处理程序。到目前为止,我有以下代码来处理上传:
public function send() {
$config = array(
'upload_path' => 'path/to/my/upload/directory',
'allowed_types' => 'pdf'
);
$this->load->library('upload', $config);
$this->upload->do_upload('pdf_upload');
echo "<pre>";
print_r($this->upload->data());
echo "</pre>";
exit();
}
而我的观点:
<?= $errors ?> <br />
<?= form_open_multipart('/Upload_test/send') ?>
<p><label for="pdf_upload">File: (PDF ONLY)</label> <input type="file" name="pdf_upload" id="pdf_upload" /></p>
<p><input type="submit" /></p>
</form>
当我提交选择了有效 PDF 文件的表单时,我会从以下位置获得以下输出print_r()
:
Array
(
[file_name] => my_file.pdf
[file_type] =>
[file_path] => path/to/my/upload/directory/
[full_path] => path/to/my/upload/directory/my_file.pdf
[raw_name] => my_file
[orig_name] =>
[client_name] => my_file.pdf
[file_ext] => .pdf
[file_size] => 4190
[is_image] =>
[image_width] =>
[image_height] =>
[image_type] =>
[image_size_str] =>
)
文件类型为空白。这可能是什么原因造成的?我错过了什么?