Welcome Guest, Not a member yet? Register   Sign In
Uploader.php function _file_mime_type fails in CI 2.1
#11

[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.
#12

[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?
#13

[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
#14

[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.
#15

[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.
#16

[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.
#17

[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.
#18

[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 ....






Theme © iAndrew 2016 - Forum software by © MyBB