CodeIgniter Forums
Uploader.php function _file_mime_type fails in CI 2.1 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Uploader.php function _file_mime_type fails in CI 2.1 (/showthread.php?tid=49194)

Pages: 1 2


Uploader.php function _file_mime_type fails in CI 2.1 - El Forum - 03-21-2012

[eluser]skunkbad[/eluser]
You can use valum's uploader, which I am using in Community Auth, but you've still got to validate the file, and if you're not going to use the CodeIgniter Upload library to do it, I hope you will at least do something similar. Also, because valum's uploader is a javascript uploader, if you plan to accommodate users who have javascript disabled, then valum's uploader isn't exactly a perfect solution or workaround. I think your best option is to revert back to an Upload library from a previous version of CodeIgniter, although the newer one that uses finfo would be considered considerably safer.


Uploader.php function _file_mime_type fails in CI 2.1 - El Forum - 03-22-2012

[eluser]Narf[/eluser]
[quote author="Djaka PM" date="1332313710"]Yup the new library still got it wrong. I think this issue only happens on *nix system.
Because when I did try my application on Windows it working correctly.
[/quote]

Can you give do some debugging and try to tell exactly what is failing?


Uploader.php function _file_mime_type fails in CI 2.1 - El Forum - 03-22-2012

[eluser]bluepicaso[/eluser]
[quote author="Narf" date="1332407837"][quote author="Djaka PM" date="1332313710"]Yup the new library still got it wrong. I think this issue only happens on *nix system.
Because when I did try my application on Windows it working correctly.
[/quote]

Can you give do some debugging and try to tell exactly what is failing?[/quote]

Simple try uploading a csv file,
mimes.php has the exact type but it just does not upload,
with valums server-side validation works too


Uploader.php function _file_mime_type fails in CI 2.1 - El Forum - 03-22-2012

[eluser]Narf[/eluser]
[quote author="bluepicaso" date="1332408714"][quote author="Narf" date="1332407837"][quote author="Djaka PM" date="1332313710"]Yup the new library still got it wrong. I think this issue only happens on *nix system.
Because when I did try my application on Windows it working correctly.
[/quote]

Can you give do some debugging and try to tell exactly what is failing?[/quote]

Simple try uploading a csv file,
mimes.php has the exact type but it just does not upload,
with valums server-side validation works too[/quote]

This doesn't tell anything other than "it doesn't work for me". Smile

Try dumping $this->upload->file_type after it fails and tell it's value. Also try editing the library and put some echo/var_dump/whatever somewhere in _file_mime_type() to see which detection method is used.


Uploader.php function _file_mime_type fails in CI 2.1 - El Forum - 05-05-2012

[eluser]otaviocarvalho[/eluser]
i'm facing the same problem, i guess something is wrong with the line #1071:

Code:
$mime = @exec($cmd, $mime, $return_status);

but till the moment i don't know what is.


Uploader.php function _file_mime_type fails in CI 2.1 - El Forum - 05-05-2012

[eluser]skunkbad[/eluser]
[quote author="otaviocarvalho" date="1336202325"]i'm facing the same problem, i guess something is wrong with the line #1071:

Code:
$mime = @exec($cmd, $mime, $return_status);

but till the moment i don't know what is.[/quote]

Some hosts block exec() and some other functions. Look for "disable_functions" in your php configuration file and see if its there.


Uploader.php function _file_mime_type fails in CI 2.1 - El Forum - 05-06-2012

[eluser]otaviocarvalho[/eluser]
Yeah, i think that could be the problem but i don't have access to the php.ini file right now, because it is hosted by my client.

The solution i found was remove the call of the function from the line #199:

Code:
$this->file_type = $_FILES[$field]['type'];

And replace with:

Code:
$this->_file_mime_type($_FILES[$field]);

Just because this is in admin part of my system and the ecommerce i'm builting don't have any uploads from the users at this time.

I think this is a poor solution (and unsecure too), but i think that a solution that breaks when you are using linux with an php installation who blocks exec() calls (what not is an uncommon situation) is as poor as my approach.


Uploader.php function _file_mime_type fails in CI 2.1 - El Forum - 07-03-2012

[eluser]Unknown[/eluser]
Hi;

T think that the solution is modifing this line:

Code:
$finfo = new finfo(FILEINFO_MIME_TYPE);

for this:

Code:
$finfo = new finfo(FILEINFO_MIME);

When you use finfo like a object you must use FILEINFO_MIME and when use finfo_file function you must use FILEINFO_MIME_TYPE, I think ....