• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mime type detection

#1
[eluser]Unknown[/eluser]
You might find this error in your log files:


Code:
ERROR - 2012-06-11 20:58:47 --> Severity: Notice  --> Undefined index:  tmp_path /ci/system/libraries/Upload.php 1058
ERROR - 2012-06-11 20:58:48 --> The filetype you are attempting to upload is not allowed.

I replaced tmp_path as suggested in the git repo fix. But the filetype error persisted.

Line 1058 in system/Upload.php
Code:
@exec('file --brief --mime-type ' . escapeshellarg($file['tmp_name']), $output, $return_code);

Ignore $file['tmp_name'].

Not all linux distributions have the --mime-type argument for the file util, for example RH5 (centos), you should rely on -i --mime option instead since is present in debian and rh distros.

Please test CI on most common linux distros Smile

I fixed it with this modification. Quick and dirty as the container function.


Code:
@exec('file -b -i ' . escapeshellarg($file['tmp_name']), $output, $return_code);

   if ($return_code === 0 && strlen($output[0]) > 0) // A return status code != 0 would mean failed execution
   {
   // $this->file_type = rtrim($output[0]);
               $this->file_type = rtrim((count(($m = explode(';', $output[0]))) > 1) ? $m[0]: $output[0]);
    return;
   }


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.