Cannot upload docx files to server using upload library

0 down vote favorite

An ‘invalid file type’ error occours when i try to upload a docx file to server using codeignitor upload function but it works fine in local server and also in case of pdf,doc and image files .

Below is my file upload script .

I use ajaxuploader to upload file


<script>
    //.......................FILE UPLOAD ...........................................
    $(function(){

        var btnUpload=$('#nefile');
        new AjaxUpload(btnUpload, {
            action: '<?php echo site_url('userdashboard/saveabstractdocument'); ?>',
            name: 'file',

            onComplete: function(file, response){

                if(response)
                {

                    if(response == 1){


                        $('#abstractdoc').css('display','none');
                        $('#abstractval').css('display','block');



                    }else{


                        //$('#metaimgval_error').html("");
                        $("#val").val(response);
                        $('#abstractval').css('display','none');
                    }


                } else
                {

                }
            }
        });
    });
    //.......................FILE UPLOAD ENDS...........................................

</script>

below is my controller function

function saveabstractdocument() {
        $abstractfile = $_FILES["file"]["name"];
        $filenme = $_FILES["file"]["name"];

        $ext = explode(".", $filenme);
        $cnt = count($ext) - 1;
        $filenme = date("m") . date("d") . date("Y") . time() . "." . $ext[$cnt];
        $fil = date("m") . date("d") . date("Y") . time();
        $config['upload_path'] = './uploads/abstract/';
        $config['file_name'] = $fil;
        $config['allowed_types'] ='pdf|doc|docx';
        $config['max_size'] = '';
        $this->load->library('upload', $config);
        if (!$this->upload->do_upload("file")) {
            $data["err"] = array('error' => $this->upload->display_errors());
           // print_r($this->upload->display_errors());exit;
            echo 1;
        } else {
            $this->load->library('session');
            $datafile = array
                (
                'fname' => $filenme
            );
            $this->session->set_userdata($datafile);

            echo $abstractfile;
        }
    }