CodeIgniter Forums
Upload library not validating properly my files - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Upload library not validating properly my files (/showthread.php?tid=65646)



Upload library not validating properly my files - meta - 07-05-2016

Hello! I'm meta and I'm from Paraguay. This ain't my first post in the Codeigniter community, as I was a fellow user in the version 2, but at my company we fell out of love with CI until this new version, when boss demanded us to use it again. Don't know what happened to the old forum and old posts, but I registered again to be part.

AND... also to request your help. 

I'm using the upload library to set background images in a project. The thing is that the validator is throwing me file types error, when I specifically set up them properly.

Here is a peek:

Code:
if ( $_FILES ) // The files uploading
{
    $this->load->library( 'upload' );

    $background['upload_path'] = './uploads/images/';
    $background['allowed_types'] = "gif|jpg|png";
    $background['overwrite'] = TRUE;
    $background['file_name'] = 'background';

    if ( $_FILES['background']['size'] > 0 )
    {
        $this->upload->initialize( $background );

        if ( ! $this->upload->do_upload( 'background' ) )
        {
            // error message with $this->upload->display_errors()
        }
        else
        {
            // success message
        }
    }
}

I don't know why I'm getting the following:

The filetype you are attempting to upload is not allowed.

Tried with a lot of images, but still the same issue.

Thanks in advance community. I hope I can contribute with tips and tricks soon. Big Grin


RE: Upload library not validating properly my files - meta - 07-05-2016

Also I forgot to mention I'm using CI 3.0.6, and PHP 5.5.26


RE: Upload library not validating properly my files - phambinh217 - 07-05-2016

i know this problem


RE: Upload library not validating properly my files - meta - 07-06-2016

(07-05-2016, 05:24 PM)phambinh217 Wrote: i know this problem

Can you help me with that please?


RE: Upload library not validating properly my files - meta - 07-06-2016

UPDATE:

I tried the * symbol as allowed type, and accepted my file. But of course, is not what I'm looking for.


RE: Upload library not validating properly my files - ivantcholakov - 07-06-2016

Is GD PHP-extension installed in your server? Does the function getimagesize() work there?