Skip to content

Problem with allowed types in upload class

Derek Jones edited this page Jul 5, 2012 · 5 revisions

I ran into an problem with allowed types in upload class. When I set into allowed types images and other files (like this 'gif|jpg|jpeg|png|iso|dmg|zip|rar|doc|docx|xls|xlsx|ppt|pptx|csv|ods|odt|odp|pdf|rtf|sxc|sxi|txt|exe|avi|mpeg|mp3|mp4|3gp') and if I want upload for example AVI them I get error about not allowed file type.

I looked into Upload class, specifically is_allowed_filetype method. I found that this method inspecting what getimagesize returns although file isnt image.

There are two solutions:

  1. rewrite allowed types so that images extensions will be at the end ('iso|dmg|zip|rar|doc|docx|xls|xlsx|ppt|pptx|csv|ods|odt|odp|pdf|rtf|sxc|sxi|txt|exe|avi|mpeg|mp3|mp4|3gp|gif|jpg|jpeg|png')

  2. download my corrected file MY_Upload class - I added one "if", that check file_type by calling method is_image.

File:MY_Upload.zip

Clone this wiki locally