Welcome Guest, Not a member yet? Register   Sign In
File Upload Class - MIME type detection error - 2.1.0
#1

[eluser]Unknown[/eluser]
There is a bug with the File Upload Class in the _file_mime_type function.

1. Uploading any image with the following config would generate the error 'The filetype you are attempting to upload is not allowed.':

Code:
$config = array(
'upload_path' => './uploads/',
'allowed_types' => 'gif|jpg|png'
);
  
$this->load->library('upload', $config);


2. Changing 'allowed_types' to '*' allows the file to be uploaded, however the upload data array ( $this->upload->data() ) contains an error:

Code:
[file_type] => cannot open `' (no such file or directory)

3. Looking at system/libraries/Upload.php , Line 1058 tries to use an array value that does not exist.

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

Changed to:

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

This seems to detect the proper MIME type.

----

System Info: PHP 5.2.11 (MAMP 1.0) - Mac OS X 10.6.8


Messages In This Thread
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 11-17-2011, 01:35 PM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 04-16-2012, 09:42 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 04-19-2012, 12:08 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 05-16-2012, 08:42 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 05-17-2012, 10:35 PM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 06-27-2012, 10:59 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-06-2012, 02:39 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-17-2012, 11:52 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-22-2012, 10:21 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-22-2012, 11:53 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-23-2012, 01:42 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 08-27-2012, 04:34 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 09-11-2012, 12:12 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 09-12-2012, 01:00 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 09-20-2012, 02:30 PM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-17-2013, 11:46 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 11-20-2013, 09:29 PM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 08-26-2014, 08:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB