2014-10-28 75 views
0

我使用BootstrapValidation驗證PhpExcel的文件。'PHPExcel_Reader_Exception'消息'無法打開閱讀!文件不存在。'

Fatal error: Uncaught exception 'PHPExcel_Reader_Exception' with message 'Could not open for reading! File does not exist.'

1:如何設置驗證不僅接受的.xls但整個文件名(file.xls)?

2:文件不POST? (見腳本)

HTML:(我需要有input name ="avatar"得到BootstrapValidation工作)

<form id="fileForm" class="form-horizontal well" action='php/import_excel.php' method="post"> 
    <div class="form-group"> 
     <h4>Välj fil...</h4> 
      <div class="col-sm-12"> 
       <input type="file" class="form-control" id="file" name="avatar" /> 
      </div> 
    </div> 
    <div class="pull-right"> 
    <button type="submit" id="Import" name="Import" class="btn btn-primary button-loading" data-loading-text="Loading...">Ladda upp</button> 
    </div> 
    <br /> 
</form> 

JS:

$(document).ready(function() { 
$('#fileForm').bootstrapValidator({ 
    feedbackIcons: { 
     valid: 'glyphicon glyphicon-ok', 
     invalid: 'glyphicon glyphicon-remove', 
     validating: 'glyphicon glyphicon-refresh' 
    }, 
    fields: { 
     avatar: { 
      validators: { 
       file: { 
        extension: 'xls', 
        type: 'application/vnd.ms-excel', 
        message: 'Välj: lkbkom.xls' 
       } 
      } 
     } 
    } 
}); 
}); 

PHP:

if(isset($_POST["Import"])){ 
echo $path=$_FILES["file"]["tmp_name"]; 
+0

HTML - >您忘記設置加密** ENCTYPE = 「的multipart/form-data的」 ** – donald123 2014-10-28 11:42:29

+0

@ donald123我已經嘗試過,但仍然沒有! – N1CKN4M3 2014-10-28 13:18:33

回答

0

故障是在.JS

fields: { 
    avatar: { 

應該是:

fields: { 
    file: { 
相關問題