'PHPExcel_Reader_Exception',消息'无法打开阅读!文件不存在。'

时间:2014-10-28 11:36:35

标签: javascript php jquery

我使用BootstrapValidation来验证PhpExcel的文件。

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"];

1 个答案:

答案 0 :(得分:0)

故障发生在.JS

fields: {
    avatar: {

应该是:

fields: {
    file: {