I've been scouring the Code Igniter forums for the past hour trying to figure this one out:
I'm writing a file upload handler for a web application using Code Igniter. I have the following code to handle the upload so far:
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();
}
And my view:
<?= $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>
When I submit the form with a valid PDF file selected, I get the following output from 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] =>
)
The file type is blank. What could be causing this? What am I missing?