Welcome Guest, Not a member yet? Register   Sign In
adding one mime type breaks the others? WTF?
#1

[eluser]vecima[/eluser]
I have a form in which I want the user to optionally upload some files.

They can upload 1 archive (zip), and as many image files (jpg|gif|png) as they want.

I had the image upload working perfectly, but the zip upload kept giving the infamous error:

Code:
The filetype you are attempting to upload is not allowed.

I checked mimes.php and noticed that my .zip was reported as an:

Code:
application/force-download

instead of any of the other mime types that zip was already defined as. so i promptly added that mime type to the zip array, and was excited to find that my .zip file uploaded just as I had hoped it would.

Joy!

not quite - now image files fail to upload, spitting that venomous error at me:

Code:
The filetype you are attempting to upload is not allowed.

Filth! Lies! Deceit!

what is up with CI's upload library? I know I'm not the only one with problems - I've read a bazillion posts to the contrary. It seems like everyone has a slightly different version of the problem too.
#2

[eluser]vecima[/eluser]
BLAGH.

CI is designed to make me look stupid by providing a helpful forum that tempts me to post a problem RIGHT before I figure it out.

I needed to call:

Code:
$this->load->library('upload');

only once.

my upload file method was calling once,
and my upload image method was calling it once.

that's why it worked until i did BOTH in a single form.
then when I fixed the zip mime type, the zip upload worked (it was first in the form) and the image one broke.

so, after I added the application/force-download to the mime types, and changed those load calls to initialize calls, and just added a single load call in an appropriate place, it's finally working as expected.

good thing I only spent all night on it.
#3

[eluser]John_Betong[/eluser]
 
I am writing a similar process and also experiencing similar problems with the error:

Code:
"The filetype you are attempting to upload is not allowed".

 

I managed to solve one problem by pre-pending the files I wanted to $config['allowed_types']

Can you give it a try and see if it works on your computer?
 
Code:
$config['allowed_types']    = 'zip|exe|com|flv|mp3|mpeg3|wav|x-wav|gif|jpg|jpeg|png|bmp|wbmp';
 
 
 
#4

[eluser]vecima[/eluser]
I'm not sure I can be of any help - you see my problem was never that allowed types weren't working. I had to add a mime type to the "zip" definition because my zip file was of the type application/force-download but once I added that it was working correctly (except that I made a stupid mistake).
#5

[eluser]John_Betong[/eluser]
[quote author="vecima" date="1253645144"]I'm not sure I can be of any help - you see my problem was never that allowed types weren't working. I had to add a mime type to the "zip" definition because my zip file was of the type application/force-download but once I added that it was working correctly (except that I made a stupid mistake).[/quote]
 
I am pleased you managed to solve your problem.
 
http://codeigniter.com/bug_tracker/bug/6780/

I have searched some more and discovered a bug in the link above but does not appear to be fixed.
 
 
 
#6

[eluser]vecima[/eluser]
odd... that bug says:

Quote:If “allowed_types” contains image types as well non image types, it’s not possible to upload a non image file

I'm uploading both, but I guess i got around it by having separate form file inputs, and seperate calls to

Code:
$this->upload->initialize($config)

are you not able to make 2 form elements, one for images, one for non-images, even as a temporary solution?




Theme © iAndrew 2016 - Forum software by © MyBB