Q:

Code Igniter File Upload - No File Type

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?

A:

I found the answer in a related, but not duplicate question: Uploading in Codeigniter - The filetype you are attempting to upload is not allowed

If you're using Codeigniter version 2.1.0 there is a bug in the Upload
  library. See http://codeigniter.com/forums/viewthread/204725/ for more
  details.
Basically what I did was modify a few lines of code in the File Upload
  Class (Location: ./system/libraries/Upload.php)
1) modify Line number 1044 
from:
$this->file_type = @mime_content_type($file['tmp_name']);
return;

to this:
$this->file_type = @mime_content_type($file['tmp_name']);
if (strlen($this->file_type) > 0) return; 

2) modify line number 1058
from:
@exec('file --brief --mime-type ' . escapeshellarg($file['tmp_path']), $output, $return_code);

to this:
@exec('file --brief --mime-type ' . escapeshellarg($file['tmp_name']), $output, $return_code); 

As you can probably see, line 1058 tries to use an array value that
  does not exist.

