2

I've set up 'Uploadify' to upload files to my server where I process them with CodeIgniter's file upload library.

However, I think Uploadify changes the mime type of the files, or does something else weird which causes CodeIgniter to give a 'the file type is not allowed' error despite it being allowed.

E.g I've allowed JPEG files but when I upload them using Uploadify, I get that error.

Is there any workaround for this? Basically, I want only image uploads to be allowed, e.g .jpg, .jpeg, .bmp, .png. Do I have to manually check the extension of the files or is there any better option?

1 Answer 1

2

You're correct, uploadify uses the mime type application/octet-stream for most (all?) the files which it uploads. I think this is actually caused by Flash handling the uploading, but I'm not 100% sure.

In your controller where you handle the upload, drop in a print_r($_FILES) and check out what the mime-type is, then just add it to your application/config/mimes.php file.

So in your mimes.php file you'll probably have something like:

'jpg'   =>  array('image/jpeg', 'image/pjpeg', 'application/octet-stream'),
Sign up to request clarification or add additional context in comments.

3 Comments

The problem is that a user can figure out the url to which uploadify uploads, and then he can upload any malicious file manually to that url and pass on the mime type octet-stream, and it will be accepted. I've instead settled for getImageSize() to confirm if a file's an image or not.
Yes, this is an issue, unfortunately it is an issue with Uploadify. Two possible solutions are recreating the uploaded image via PHP's GD library after the upload (any non-image file will throw an error) or find another upload script.
what about bmp file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.