503服务不可用服务器暂时繁忙,请稍后再试

时间:2019-11-12 06:32:31

标签: php spreadsheet xlsx

我曾经使用过这样的php电子表格

    <?php 
include 'connection.php';
require '../vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Reader\Csv;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;

$file_mimes = array('application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');

if(isset($_FILES['filerecon']['name']) && in_array($_FILES['filerecon']['type'], $file_mimes)) {

    $arr_file = explode('.', $_FILES['filerecon']['name']);
    $extension = end($arr_file);
    if('csv' == $extension) {
        $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
    } else {
        $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
    }

    $spreadsheet = $reader->load($_FILES['filerecon']['tmp_name']);

    $sheetData = $spreadsheet->getActiveSheet()->toArray();
    //$i = 1;
    unset($sheetData[0]);



    // $highestRow = $spreadsheet->getActiveSheet()->getHighestRow();

    // echo $highestRow;
    // die;

    $month = $_POST['bulanrecon'];

    foreach ($sheetData as $key => $value) {
        $value = str_replace(["'", '"'], '', $value);
        $ket = 'Anomali';
        if ($value[13] != '') {
            $data = mysqli_fetch_object(mysqli_query($conn, "SELECT COUNT(*) as t FROM new_data_recon WHERE pots_gabungan = '".$value[13]."' AND bulan_input = $month"))->t;
            if ($data > 0) {
                if ($data == 1) {
                    mysqli_query($conn, "UPDATE new_data_recon SET ket_wiw = 'Duplikat (IKR+SETTING)' WHERE pots_gabungan = '".$value[13]."'");
                }
                $ket = 'Duplikat (SETTING)';
            }
            else {
                $ket = 'Clear';
            }
        }

        $sql = "INSERT INTO new_data_recon (id, nomor, regional, witel, datel, sto, order_id, package_name, type_transaksi, jenis_layanan, alpro, ncli, pots, speedy, pots_gabungan, status_resume, status_message, order_date, last_update_status, nama_cust, no_hp, alamat, k_contact, longitude, latitude, area, tanggal, bulan_rec, ket, bulan_input, ket_wiw)
            VALUES ('', '$value[0]', '$value[1]', '$value[2]', '$value[3]', '$value[4]', '$value[5]', '$value[6]', '$value[7]', '$value[8]', '$value[9]', '$value[10]', '$value[11]', '$value[12]', '$value[13]', '$value[14]', '$value[15]', '$value[16]', '$value[17]', '$value[18]', '$value[19]', '$value[20]', '$value[21]', '$value[22]', '$value[23]', '$value[24]', '$value[25]', '$value[26]', '$value[27]', '$month', '$ket')";

        mysqli_query($conn, $sql);
    }

    header("location: https://www.blablabla.id/");
    mysqli_close($conn);
}
?>

我无法正常工作,但是只是0-16000行xlsx之间的数据,如果我导入更高的数据,则会收到此错误“ 503 暂停服务 服务器暂时很忙,请稍后再试!“

我该怎么办,您能给我解决的示例代码吗?

1 个答案:

答案 0 :(得分:0)

请在顶部添加此代码

ini_set("max_execution_time", "-1");
ini_set("memory_limit", "-1");
set_time_limit(0);

并运行一次脚本