Can't updload csv file with upload->do_upload() |
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 ?
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 ![]() (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.
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.
I have merged the CI3 mimes.php with CI2.2.1.
And it works ! Thanks for your help !
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. (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. |
Welcome Guest, Not a member yet? Register Sign In |