Upload File Bug - 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: Upload File Bug (/showthread.php?tid=18232) |
Upload File Bug - El Forum - 05-20-2009 [eluser]B3ll4triX[/eluser] Fatal error: Call to undefined function finfo_open() in /home/xeenit/public_html/UQYG.com/system/libraries/Upload.php on line 195 Upload File Bug - El Forum - 05-20-2009 [eluser]Dregond Rahl[/eluser] [quote author="B3ll4triX" date="1242897630"]Fatal error: Call to undefined function finfo_open() in /home/xeenit/public_html/UQYG.com/system/libraries/Upload.php on line 195[/quote] sorry was editing something. try now =] Upload File Bug - El Forum - 05-20-2009 [eluser]B3ll4triX[/eluser] sorry, the problem is not in upload library, but i wrong in use download helper... thanks for apply... Upload File Bug - El Forum - 05-20-2009 [eluser]Cheater[/eluser] Ideally the upload library should use FileInfo to validate all files where avaliable. Right now it only validates images with getimagesize. Remember: The MIME type that the upload library gets is supplied by the browser - its accuracy is not guaranteed and you can not rely on it. People having problems with pdf files, that is why your having trouble. Upload File Bug - El Forum - 05-21-2009 [eluser]Josepzin[/eluser] I have modified the PDF type definition in aplication/config/mimes.php Code: 'pdf' => array('application/pdf', 'application/x-download', 'application/download'), Upload File Bug - El Forum - 05-21-2009 [eluser]Dregond Rahl[/eluser] [quote author="Josepzin" date="1242906247"]I have modified the PDF type definition in aplication/config/mimes.php Code: 'pdf' => array('application/pdf', 'application/x-download', 'application/download'), you need to add Code: application/octet because that's what is being sent, and being a problem. Upload File Bug - El Forum - 05-21-2009 [eluser]Cheater[/eluser] [quote author="Dregond Rahl" date="1242907815"]you need to add Code: application/octet because that's what is being sent, and being a problem.[/quote] Err Dont you mean application/octet-stream? Upload File Bug - El Forum - 05-21-2009 [eluser]Dregond Rahl[/eluser] yup application/octet-stream i copied it wrong XD Upload File Bug - El Forum - 06-10-2009 [eluser]Unknown[/eluser] Hopefully this helps. I tried every variation of the posts to try to get CI to accept PDF, INDD, AI, ZIP files and more. Messing with the mime types did not seem to help. I found a fix to add to the Upload.php file within the is_allowed_filetype function. The problem seems to be within the foreach loop. I don't claim to be a good programmer, but I think the fact that within every condition in this loop, there is a return true or return false which breaks the loop?? (feel free to correct me if I am wrong) Here is my updated code: Code: function is_allowed_filetype() If you add the file types you are experiencing errors with in that $error_types array, then the upload function works with those files you experience issues with where the mime type does not fix. I hope this helps others who had the same issues as me. Upload File Bug - El Forum - 06-11-2009 [eluser]Josepzin[/eluser] I quoted my very, very simple solution, really, is simple and easy, without make changes to the /system code. Is necessary only one line of code before upload the file, it search the extension of the selected file to upload in the allowed types: Code: $config['allowed_types'] = substr( Example: Code: $allowed_types = 'pdf|doc|jpg|zip|png|gif'; // <--- your allowed types The result of this code is: Quote:With $_FILES['userfile']['name'] = 'document.pdf'; Or: Quote:With $_FILES['userfile']['name'] = 'image.jpg'; Another with incorrect type: Quote:With $_FILES['userfile']['name'] = 'terrible_mortal_virus.exe'; |