Blogger Information
Blog 51
fans 0
comment 1
visits 64963
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Fastadmin在弹窗层上传文件
鱼的熊掌
Original
1235 people have browsed it

在add.hml导入excel
html代码

  1. //在弹窗的页面js引用上传组件
  2. template: function () {
  3. Table.api.init({
  4. extend: {
  5. import_url: 'yq/flowld/import'
  6. }
  7. });
  8. require(['upload'], function (Upload) {
  9. Upload.api.plupload($(".btn-import"), function (data, ret) {
  10. Fast.api.ajax({
  11. url: "yq/flowld/import", //上传接收地址
  12. data: {file: data.url},
  13. success: function (response) {
  14. console.log(response);
  15. layer.closeAll();
  16. }
  17. }, function (data, ret) {
  18. // console.log(data);
  19. // console.log(ret);
  20. });
  21. });
  22. });
  23. Controller.api.bindevent();
  24. }

JS代码

  1. /**
  2. * @description: 导入
  3. * @return {*}
  4. */
  5. public function import()
  6. {
  7. $file = $this->request->request('file');
  8. if (!$file) {
  9. $this->error(__('Parameter %s can not be empty', 'file'));
  10. }
  11. $filePath = ROOT_PATH . DS . 'public' . DS . $file;
  12. if (!is_file($filePath)) {
  13. $this->error(__('No results were found'));
  14. }
  15. $objReader = \PHPExcel_IOFactory::createReader('Excel2007');
  16. $objPHPExcel = $objReader->load($filePath, $encode = 'utf-8');
  17. $sheet = $objPHPExcel->getSheet(0);
  18. $highestRow = $sheet->getHighestRow(); // 取得总行数
  19. $highestColumn = $sheet->getHighestColumn(); // 取得总列数
  20. $this->success('111');
  21. }

PHP

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post