![]() |
Can't updload csv file with upload->do_upload() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Can't updload csv file with upload->do_upload() (/showthread.php?tid=1068) |
Can't updload csv file with upload->do_upload() - bvrignaud - 02-09-2015 Hello everybody, I try to upload csv but it doesn't work and I don't understand why. I use the documentation's example. This is my controller PHP Code: class Prof extends CI_Controller { If I use allowed_types = 'csv', it's not ok, but if I use something else like '*' it's Ok Any Idea please ? RE: Can't updload csv file with upload->do_upload() - mariek - 02-09-2015 First check in your config file (mimes.php) if CSV is there and what are mimes attached to it. Than check your file mime type with something like : Code: <form method="post" action="" enctype="multipart/form-data"> If the mime is not in the config array, add it. If it is.... well, dunno ![]() RE: Can't updload csv file with upload->do_upload() - Narf - 02-09-2015 (02-09-2015, 08:18 AM)mariek Wrote: First check in your config file (mimes.php) if CSV is there and what are mimes attached to it. The MIME-type found in the $_FILES array is ignored ... that's the whole point. What you see in $_FILES is client input and should not be trusted. RE: Can't updload csv file with upload->do_upload() - bvrignaud - 02-09-2015 My mimes.php : PHP Code: $mimes = array( 'hqx' => 'application/mac-binhex40', Mi view : PHP Code: <?=form_open('prof/import', 'class="form-inline"')?> And I add my capture. $this->upload->display_errors() return : Le type de fichier que vous tentez d'envoyer n'est pas autorisé. ( = The type of file you are trying to send is not allowed.). I have no problem with other file. RE: Can't updload csv file with upload->do_upload() - bvrignaud - 02-09-2015 I try this way : https://stackoverflow.com/questions/4731071/uploading-a-csv-into-codeigniter An it's works ! strange ? RE: Can't updload csv file with upload->do_upload() - bvrignaud - 02-09-2015 I have merged the CI3 mimes.php with CI2.2.1. And it works ! Thanks for your help ! RE: Can't updload csv file with upload->do_upload() - mariek - 02-09-2015 Yep, strange, maybe CI has changed recently on this point. It works on my recent projects (CI 2.1). @Narf : I know user input should not be trusted but it is the way CI does it. My point was only to check what mime type is detected by the script, to check if it's in CI config array. RE: Can't updload csv file with upload->do_upload() - Narf - 02-09-2015 (02-09-2015, 09:40 AM)mariek Wrote: Yep, strange, maybe CI has changed recently on this point. It works on my recent projects (CI 2.1). It's not how CI does it - that was my point. $_FILES[$file]['type'] is an absolutely last-resort assumption in CI's MIME type detection. If you're reaching it, it means that you have none of the following: - ext/fileinfo (finfo_file()), which is bundled and installed with PHP by default since version 5.3) - exec(), shell_exec(), popen() and /usr/bin/file under a UNIX-based OS (or you're using Windows) - mime_content_type() CodeIgniter will attempt to use all of the above (in the order they're listed) before it falls back to the browser-specified value that is in $_FILES, so virtually no application should be ever relying on that one. |