亚州天堂爱爱,做爱视频国产全过程在线观看,成人试看30分钟免费视频,女人无遮挡裸交性做爰视频网站

? ? ?

Modal模態框+Ajax+PHPExcel 帶進度條上傳Excel至mysql

研究了很久怎么在模態框中上傳Excel,并且顯示進度條,最后還是采用迂回戰術。。利用iframe…測試在chorme可以運行。。

1index.html

Modal模態框+Ajax+PHPExcel 帶進度條上傳Excel至mysql

<section class="content"> <div class="container-fluid"> <div class="card"> <!--<div class="card-header">--> <div class="card-body"> <div class="row"> <div class="col-md-12"> <div id="toolbar"> <form class="form-inline"> <div class="form-group"> <div class="input-group input-group-sm" id="query_items"> <div class="input-group-prepend"> <span class="input-group-text">Month</span> <span class="input-group-text"> <i class="far fa-calendar-alt"></i></span> </div> <input type="text" class="form-control" id="mth_choose" size="25" /> </div> <div class="input-group input-group-sm p-1" id="slic_q"> <div class="input-group-prepend"> <span class="input-group-text">SLIC</span> </div> <div class="input-group-prepend"> <select id="q_slic" class="form-control"> </select> </div> </div> <div class="input-group input-group-sm mr-2" id="btn_q"> <span class="input-group-append"> <button type="button" class="btn btn-info btn-flat btn-sm" id="query_base"> <i class="fas fa-search"></i></button> </span> </div> <div class="btn-group btn-group-sm p-1" id="btn_grp"> <button id="u_wgt" class="btn btn-success btn-sm mr-2" data-toggle="modal" data-target="#upload_wgt" type="button" disabled><i class="fas fa-upload"></i>Weight</button> <button id="u_inf" class="btn btn-info btn-sm mr-2" data-remote="child_page/test.php" data-toggle="modal" data-target="#upload_info" type="button"><i class="fas fa-upload"></i>Basic Info</button> <button id="d_exp" class="btn btn-primary btn-sm mr-2" data-toggle="modal" data-target="#dowload_exp"><i class="fas fa-download"></i>Export</button> </div> </div> </form> </div> </div><!-- /.toolbar --> </div> <!-- /.row --> <!--</div> /.card header --> <!-- <div class="card-body"> --> <div class="row"> <div class="col-md-12"> <table id="incentive_table" class="table table-bordered table-striped table-sm"></table> </div> </div> </div><!-- /.card body --> </div><!-- /.card --> </div><!-- /.container-fluid --></section>

2點擊Weight按鈕后彈出模態框

Modal模態框+Ajax+PHPExcel 帶進度條上傳Excel至mysql

<!--weight upload Modal--><div class="modal fade" id="upload_wgt" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" id="myModalLabel">Upload Weight</h4> <button type="button btn-sm" class="close" data-dismiss="modal" aria-hidden="true"> × </button> </div> <div class="modal-body"> <span id="message"></span> <form id="frm_upload_wgt" method="POST" enctype="multipart/form-data" class="form-horizontal"> <div class="form-group" align="center"> <label class="col-md-4 control-label">Select Upload File</label> <input type="file" name="file" id="file" /> </div> <div id='load_frm' class="form-group"> <iframe id="wgt_load_frm" src="" width="100" height="50" frameborder='no' scrolling="no"></iframe> </div> <div class="form-group" align="center"> <input type="hidden" name="hidden_field" value="1" /> <button type="submit" class="btn btn-info" id="wgt_import" disabled> <i class="fa fa-upload p-1"></i> Upload </button> <button type="button" class="btn btn-danger" id="close_list" data-dismiss="modal"> <i class="fa fa-times p-1"></i> Close </button> </div> </form> <span id="message"></span> </div> </div> </div></div><!--weight upload Modal end-->

3選擇文件后點擊上傳,然后在iframe中顯示進度條

Modal模態框+Ajax+PHPExcel 帶進度條上傳Excel至mysql

3.1 index.html中的Jquery

$("#u_wgt").on("click", function () { $("#frm_upload_wgt")[0].reset(); document.getElementById("wgt_load_frm").src = ""; $("#wgt_import").removeAttr("disabled", "true"); $('#frm_upload_wgt').on('submit', function (event) { $('#message').html(''); event.preventDefault(); $.ajax({ url: "child_page/upload_files/upload_excel_file.php", method: "POST", data: new FormData(this), dataType: "json", contentType: false, cache: false, processData: false, beforeSend: function () { var file = document.getElementById('file').files[0]; var fileName = file.name; if (fileName.endsWith("xlsx")) { $("#wgt_import").attr("disabled", "true"); } else { modal_js.fail({ 'msg': 'Just Accept .xlsx file', 'icon': 2 }); $('#file').val(''); return false; } }, success: function (data) { if (data.success) { var file_name = data.file_name; var main = document.getElementById("load_frm"); var iframe = document.getElementById("wgt_load_frm"); var width = main.offsetWidth; var height = main.offsetHeight; iframe.style.width = width "px"; iframe.style.height = (height - 100) "px"; document.getElementById("wgt_load_frm").src = "child_page/upload_files/upload_pu_weight.php?file=" file_name; } if (data.error) { $('#message').html('<div class="alert alert-danger">' data.error '</div>'); $("#wgt_import").removeAttr("disabled", "true"); } } }) }); });

3.2 upload_excel_file.php

<?php$file = $_FILES['file']['name'];$filetempname = $_FILES['file']['tmp_name'];$filePath = '../../upFile/';require_once('../../plugins/PHPExcel/PHPExcel.php');require_once('../../plugins/PHPExcel/PHPExcel/IOFactory.php');require_once('../../plugins/PHPExcel/PHPExcel/Reader/Excel2007.php');//require_once ('../PHPExcel/PHPExcel/Reader/CSV.php');$filename = explode(".", $file); //把上傳的文件名以“.”好為準做一個數組。$time = date("y-m-d-H-i-s"); //去當前上傳的時間$filename[0] = $time; //取文件名t替換$name = implode(".", $filename); //上傳后的文件名$uploadfile = $filePath . $name; //上傳后的文件名地址$result = move_uploaded_file($filetempname, $uploadfile); //假如上傳到當前目錄下if ($result) //如果上傳文件成功,就執行導入 excel操作{ $output = array( 'success' => true, 'file_name' => $uploadfile ); echo json_encode($output);}

3.3 upload_pu_weight.php

<!DOCTYPE html><html lang="en"><head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta http-equiv="x-ua-compatible" content="ie=edge" /> <title>Upload</title></head><body> <div id="progress" class="inline" style="width:700px;border:1px solid #ccc;"></div> <div id="information" class="inline"></span></body></html><?phpset_time_limit(0);require_once("../../connections/ie_mysql_li_db.php");$sqls = new Mysqldb();if (isset($_GET['file'])) { //下面的路徑按照你PHPExcel的路徑來修改 require_once('../../plugins/PHPExcel/PHPExcel.php'); require_once('../../plugins/PHPExcel/PHPExcel/IOFactory.php'); require_once('../../plugins/PHPExcel/PHPExcel/Reader/Excel2007.php'); //require_once ('../PHPExcel/PHPExcel/Reader/CSV.php'); $uploadfile = $_GET['file']; $str = ""; // $objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel2003 $objReader = PHPExcel_IOFactory::createReader('Excel2007'); //use excel2003 和 2007 format //$objReader = PHPExcel_IOFactory::createReader('CSV');//use CSV $objPHPExcel = PHPExcel_IOFactory::load($uploadfile); $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); // 取得總行數 $rownum = $highestRow - 1; $highestColumn = $sheet->getHighestColumn(); // 取得總列數 for ($j = 2; $j <= $highestRow; $j ) { $percent = intval($j / $highestRow * 100) . "%"; echo '<script language="javascript"> document.getElementById("progress").innerHTML="<div style="width:' . $percent . ';background-image:url(../../img/pbar-ani.gif);"> </div>"; document.getElementById("information").innerHTML="' . $percent . ' - ' . $j . ' in TTL ' . $highestRow . ' processed."; </script>'; echo str_repeat(' ', 1024 * 8); flush(); sleep(0.8); for ($k = 'A'; $k <= $highestColumn; $k ) { $str .= iconv('utf-8', 'gbk', $objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue()) . '||'; //讀 取單元格 } $strs = explode("||", $str); $w_slic = $strs[0]; $w_trk = $strs[1]; $w_billing_weight = $strs[2]; $w_update = date('Y-m-d'); $sql = "replace into tbl_pu_weight( w_slic, w_trk, w_billing_weight, w_update ) values ( '" . $w_slic . "', '" . $w_trk . "', '" . $w_billing_weight . "', '" . $w_update . "' )"; $sqls->simple_query($sql); $str = ""; } unlink($uploadfile); //刪除上傳的excel文件 echo '<script language="javascript"> document.getElementById("information").innerHTML="Upload Successful!"; </script>';}else { echo '<script language="javascript"> document.getElementById("information").innerHTML="Upload Faile!"; </script>';}?>

3.4 進度條圖片。。pbar-ani.gif

Modal模態框+Ajax+PHPExcel 帶進度條上傳Excel至mysql

版權聲明:本文內容由互聯網用戶自發貢獻,該文觀點僅代表作者本人。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如發現本站有涉嫌抄襲侵權/違法違規的內容, 請發送郵件至 舉報,一經查實,本站將立刻刪除。

(0)
上一篇 2022年11月12日 上午10:49
下一篇 2022年11月12日 上午11:03

相關推薦

  • 前端項目簡歷寫管理系統

    前端項目簡歷管理系統 管理系統是許多企業和個人都需要的一個工具,可以幫助他們管理和控制他們的業務流程。作為一名前端開發人員,我可以負責設計和開發一個基本的管理系統,該系統可以包含一…

    科研百科 2025年6月17日
    0
  • 批零商企等傳統商貿企業如何數字化轉型?(傳統零售企業如何有效地進行數字化轉型-)

    傳統商貿企業的業務業務涵蓋貿易、物流和倉儲全流程,以進貨、銷售、管理為核心的進銷存管理就成為重中之重。 但因市場大環境影響,傳統商貿企業在運營成本與運作流程上都受到了沖擊,尤其在內…

    2022年8月29日
    185
  • 小區黨支部基層觀察點工作法

    小區黨支部基層觀察點工作法 小區黨支部基層觀察點工作法是一種有效的黨支部工作方法,能夠幫助黨支部更好地了解社區居民的需求和問題,并有效地幫助他們解決。本文將介紹小區黨支部基層觀察點…

    科研百科 2024年12月6日
    4
  • 工程師筆記 多維度監控Dell 13G 服務器陣列卡磁盤狀態(dell服務器陣列卡設置)

    隨著軟件定義概念的興起,越來越多廠商和用戶在推廣軟件定義的方案,其中軟件定義存儲相對于傳統存儲定義架構,不但在成本上節省,在運維難度及規模上也同樣更勝一籌。 多維度監控Dell 1…

    2022年8月23日
    567
  • 免費軟件項目管理軟件

    免費軟件項目管理軟件 項目管理軟件是一個非常重要的工具,能夠幫助項目經理有效地管理項目進度、預算和質量。目前市面上有很多免費的項目管理軟件可供選擇,本文將介紹其中幾種。 1. Ji…

    科研百科 2024年7月27日
    41
  • 陜西教育廳科研計劃項目2023

    陜西教育廳科研計劃項目2023 近年來,陜西省教育廳一直致力于推動教育事業的健康發展。為了進一步提高陜西省教育的質量,陜西省教育廳決定開展一項科研計劃項目,旨在推動教育信息化建設,…

    科研百科 2024年12月4日
    0
  • 攪活供應商管理“一池春水”(攪動一池春水)

    供應商管理貫穿項目管理全過程,是一個動態管理過程。有效優化對供應商的尋源、選擇、考核評價及獎勵與退出機制四個主要環節的系統化管理,實現對供應商全生命周期的管理,可以充分攪活供應商管…

    科研百科 2022年12月13日
    112
  • g206大渡口至東流段一級公路改建工程2024

    G206大渡口至東流段一級公路改建工程2024 近年來,隨著中國經濟的快速發展,公路交通事業也取得了巨大的進步。然而,隨著車輛數量的不斷增加,公路交通擁堵問題也日益嚴重。因此,G2…

    科研百科 2024年11月6日
    42
  • 江蘇省省級重點實驗室名單

    江蘇省省級重點實驗室名單 江蘇省是一個歷史悠久、文化底蘊深厚的省份,擁有著豐富的自然資源和人力資源。為了推動江蘇省的科技創新,提高科技創新能力,江蘇省政府于2007年設立了一批省級…

    科研百科 2024年11月10日
    1
  • 科研項目郵件

    科研項目郵件 尊敬的XXX老師: 您好!我是XXX,是您的XXX項目的學生。我希望您能收到我的郵件,并能夠回復我。 首先,我想感謝您的指導。您的課程非常有趣,并且提供了很多有用的資…

    科研百科 2025年2月18日
    2