首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用PHPExcelReader解析文件并将值存储在未找到的数组文件中

使用PHPExcelReader解析文件并将值存储在未找到的数组文件中
EN

Stack Overflow用户
提问于 2015-09-22 20:24:17
回答 1查看 177关注 0票数 0

我正在使用PHPExcelReader解析一个excel文件(由用户从他们的本地机器中选择)。PHP将获取这些值,并将其存储在数组中,然后重新组织,并以表的形式在屏幕上显示。

但是,在浏览文件之后,一旦单击"Submit",就会得到错误:File not found

下面是HTML:

代码语言:javascript
复制
<div class="row-fluid" style="margin-top:15px">
<h2>Step 1: Import the file</h2>
<p>Once uploaded, the window will display a preview of the document. Please check to make sure the column
    headers match the data before uploading.</p>

<form action="../scripts/previewFile.php" method="post" enctype="multipart/form-data">
    <input type="file" name="fileToUpload" />
    <input type="submit" value="Preview File" name="submit">

    <div id="filePreview" style="height: 500px; overflow: scroll;">

    </div>
</form>
</div>

调用的previewFile.php文件:

代码语言:javascript
复制
function previewFile()
{
    $filePath = $_FILES['file']['tmp_name'];

    $excel = new Spreadsheet_Excel_Reader;      // creates object instance of the class
    $excel->read($filePath);

}

更新错误为文件"previewFile.php“的404,该文件被调用为操作。

不确定我的URL "../scripts/previewFile.php"有什么问题

下面是我的模式:

代码语言:javascript
复制
root
   |_views
        |_default
            |_assets
            |_scripts
                 |_previewFile.php
            |_templates
                 |_step1.php <- the html file with the input tags
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-22 20:32:13

您的输入名为fileToUpload,您正在查找$_FILES数组中的file,因此应该如下所示:

代码语言:javascript
复制
function previewFile()
{
    $filePath = $_FILES['fileToUpload']['tmp_name'];

    $excel = new Spreadsheet_Excel_Reader;      // creates object instance of the class
    $excel->read($filePath);

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32726181

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档