Upload filetype not allowed?? - 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 filetype not allowed?? (/showthread.php?tid=27614) |
Upload filetype not allowed?? - El Forum - 02-16-2010 [eluser]123wesweat[/eluser] Hi, i have set these filetypes as allowed Code: $config['allowed_types'] = 'doc|docx|gif|jpeg|pdf|jpg|rtf|txt|text'; filetypes .doc .docx jpg gif jpeg all upload correct but .pdf .txt .text .rtf doesn't upload??? How can i fix this?? btw this is my htaccess Code: <IfModule mod_rewrite.c> Upload filetype not allowed?? - El Forum - 02-16-2010 [eluser]rogierb[/eluser] Check the mimes.php. See what types are set for .txt .rtf etc. Then check your files to see if the mimes match. If they are not in mimes.php, add them:-) Upload filetype not allowed?? - El Forum - 02-16-2010 [eluser]123wesweat[/eluser] hmm, mimes.php reads Code: 'txt' => 'text/plain', looks good to me. How can i check the mime type of a file i am uploading??? I tried Code: $uploadFile = $this->upload->data(); Any other suggestions?? Upload filetype not allowed?? - El Forum - 02-16-2010 [eluser]hqhdn[/eluser] Quote:How can i check the mime type of a file i am uploading??? You can try to use: Code: $_FILES[name]['type'] Upload filetype not allowed?? - El Forum - 02-16-2010 [eluser]rogierb[/eluser] You can echo the upload array with $this->upload->data(); An explanation of the array can be found in the userguide. http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html Upload filetype not allowed?? - El Forum - 02-16-2010 [eluser]hqhdn[/eluser] In this case: $this->upload->data() is NULL because the file doesn’t uploaded. You only can get information from $this->upload->data() until the file was uploaded on server. You can see it in library/Upload.php Code: // Set the uploaded data as class variables Upload filetype not allowed?? - El Forum - 02-16-2010 [eluser]rogierb[/eluser] The file type is checked after that part of code. I guess should be filled... What error message do you get when uploading the files? Upload filetype not allowed?? - El Forum - 02-16-2010 [eluser]123wesweat[/eluser] this is the error i get Code: Array ( [error] => Upload filetype not allowed?? - El Forum - 02-16-2010 [eluser]rogierb[/eluser] hmm, weird. What you can do is temporarily edit Upload.php Code: print_r($_FILES); Just to see what $_FILES produces and what file_type CI creates. Upload filetype not allowed?? - El Forum - 02-17-2010 [eluser]123wesweat[/eluser] hmm, .txt gives Code: Array ( [userfile] => Array ( [name] => test.txt [type] => text/plain [tmp_name] => /tmp/phpFua8uJ [error] => 0 [size] => 92 ) ) text/plain .rtf gives Code: Array ( [userfile] => Array ( [name] => test_upload.rtf [type] => text/rtf [tmp_name] => /tmp/phptEheEf [error] => 0 [size] => 2207 ) ) text/rtf .pdf gives Code: Array ( [userfile] => Array ( [name] => route.pdf [type] => application/pdf [tmp_name] => /tmp/php6b4ubb [error] => 0 [size] => 84853 ) ) application/pdf All look ok to me. |