Welcome Guest, Not a member yet? Register   Sign In
File Upload?
#1

[eluser]JasonS[/eluser]
Is anyone else having trouble uploading images with the file upload class?

Code:
if ($this->input->post('Upload')) {
    $config['upload_path'] = getcwd().'/uploads';
    $config['allowed_types'] = '*';
    //$config['allowed_types'] = 'gif|jpg|png';
    $config['max_size']    = '4000';
    $config['max_width']  = '2048';
    $config['max_height']  = '1536';
    $this->load->library('upload', $config);
            
    $this->upload->do_upload('Filedata');
    die();
}

When I set the allowed_types to * everything uploads fine. If I set it to gif|jpg|png it fails and logs the following error.

Quote:ERROR - 2011-05-09 16:21:17 --> The filetype you are attempting to upload is not allowed.

I have attached an image I have tried so far. I also downloaded today's Google logo and got the same error.. Any ideas?
#2

[eluser]gullah[/eluser]
I'm not sure exactly how it works but what if you just try removing that line? I think it'll just allow all types then.

Edit: Misread the original post. Ignore me.
#3

[eluser]JasonS[/eluser]
Using * allows all file types.. I do not want to allow all file types. I only want to allow images. This library has this capability but it isn't working.

It is only 6 lines of code.. I can't see where the mistake is..
#4

[eluser]James Mills[/eluser]
Hi,

Just had a quick look at this and I do not see why you would be getting an error. Have you tried limiting it to just jpg to start with and test this?

James
#5

[eluser]d1a8lo24[/eluser]
try using firebug to see what is being submitted.

I had a problem like this in past but i was using a javascript uploader that use a flash object. and what I learn was that flash doesn't give a mime when uploading, the file will have a mime/extension of application/octet-stream no matter what you uploaded.

Again I only had this problem when i was using this javascript uploader that used flash.

Firebug should help you out to see what the for is submitting.
#6

[eluser]JasonS[/eluser]
[quote author="d1a8lo24" date="1304999086"]try using firebug to see what is being submitted.

I had a problem like this in past but i was using a javascript uploader that use a flash object. and what I learn was that flash doesn't give a mime when uploading, the file will have a mime/extension of application/octet-stream no matter what you uploaded.

Again I only had this problem when i was using this javascript uploader that used flash.

Firebug should help you out to see what the for is submitting.[/quote]

This sounds like my problem! I am using swfobject. Did you find a workaround for this or do I need to write my own little library?
#7

[eluser]d1a8lo24[/eluser]
My solution was to edit the file mimes under application/config/mimes.php and add the application/octet-stream to the array of the files i wanted to upload. In my case JPEG, JPG, JPE, GIF, and PNG.

I was able to upload then but just like face book i knew that i would need to also create a form for the peope that didn't have javascript enable at the end i didn't integrate the javascript uploader.

Another reason why was because would need to do more validation afterwords just to make sure what kind of file was uploaded.

By the way the uploader that i was using was uploadify.




Theme © iAndrew 2016 - Forum software by © MyBB