Skip to content
This repository

Problem with allowed types in upload class 

derekjones edited this page · 5 revisions
Clone this wiki locally

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.

Something went wrong with that request. Please try again.