如何通过jquery发送它时在PHP中读取Excel文件数据

时间:2023-01-15 14:30:34

This is my jquery code which sends data to php file -

这是我的jquery代码,它将数据发送到php文件 -

jQuery("#btn_upload").click(function(){
    var exceldata = jQuery("#form_imput_field").serialize();
    var url = "phpfilepath/get-data-from-excel/exceldata/" + exceldata;
    if( exceldata != "" )
    {
        jQuery.ajax({
            url: url,
            type: 'post',
            success: function(data)
            {
                alert(data);
            }
        })
    }
    else
    {
        alert("I am in else");
    }
});

My PHP Method -

我的PHP方法 -

public function get-data-from-excel()
{
    //Get All Parameter data
    $params = $this->_getAllParams();
    echo "<pre>";print_r($params);die;
}

How can I read Excel data from this ? To create Excel I used PHP EXCEL previously but could get it to use in read as I dont know how to split data from this stream.

如何从中读取Excel数据?为了创建Excel,我之前使用过PHP EXCEL但是可以在阅读中使用它,因为我不知道如何从这个流中分割数据。

Current alert output - MAX_FILE_SIZE=134217728

当前警报输出 - MAX_FILE_SIZE = 134217728

1 个解决方案

#1


0  

If you are trying to submit a <input type="file"/> tag using JQuery and AJAX bad news, you can't do that with JQuery alone. You need to use a plugin to archieve that. For example iframe-post-form.

如果您尝试使用JQuery和AJAX坏消息提交标记,则不能单独使用JQuery。您需要使用插件来实现这一目标。例如iframe-post-form。

Once you have the excel file in your server (stored in some temporal dir for example) you should be able to read it using PHPExcel.php

一旦在服务器中有excel文件(例如存储在某个临时目录中),您应该能够使用PHPExcel.php读取它。

#1


0  

If you are trying to submit a <input type="file"/> tag using JQuery and AJAX bad news, you can't do that with JQuery alone. You need to use a plugin to archieve that. For example iframe-post-form.

如果您尝试使用JQuery和AJAX坏消息提交标记,则不能单独使用JQuery。您需要使用插件来实现这一目标。例如iframe-post-form。

Once you have the excel file in your server (stored in some temporal dir for example) you should be able to read it using PHPExcel.php

一旦在服务器中有excel文件(例如存储在某个临时目录中),您应该能够使用PHPExcel.php读取它。