无法使用上传库将docx文件上传到服务器

无法使用上传库将docx文件上传到服务器

问题描述:

当我尝试使用codeignitor上传功能将docx文件上传到服务器时出现'无效文件类型'错误,但它在本地服务器中正常工作,并且在pdf,doc和图像文件。无法使用上传库将docx文件上传到服务器

下面是我的文件上传脚本。

我用ajaxuploader上传文件

<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> 
下面

是我的控制器功能

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; 
     } 
    } 

为什么don'y你使用这样考虑......

<input type="file" name="file"/> 

或在你的问题无效类型也许它不包括在你的mimes.php doc,pdf,docx 和你r $ config ['max_size'] ='';如果你不能提供任何价值,你可以删除它。

也是在这里我上传文件的样本

$config['upload_path'] = './files/contracts-csv/'; 
       $config['allowed_types'] = 'csv'; 
       $config['max_size']  = '4096';  
       $config['overwrite']  = TRUE; 

       $this->load->library('upload', $config); 
       $this->upload->display_errors('', ''); 

       if (!$this->upload->do_upload("csv_file")) { 
         echo $this->upload->display_errors(); die(); 
         $this->data['error'] = array('error' => $this->upload->display_errors()); 
       } else { 
        $upload_result = $this->upload->data(); 
        $pathfile = $upload_result['full_path']; 
       } 

...的希望我给你的想法