car_import.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: lionared
  5. * Date: 2018/3/15
  6. * Time: 上午11:18
  7. */
  8. defined('InShopNC') or exit('Access Invalid!');
  9. require_once(BASE_ROOT_PATH . '/helper/car/importer.php');
  10. class car_importControl extends SystemControl {
  11. public function __construct(){
  12. parent::__construct();
  13. }
  14. public function indexOp()
  15. {
  16. if(isset($_POST['import'])) {
  17. $file = $_FILES['csv_cars'];
  18. $file_type = substr(strstr($file['name'], '.'), 1);
  19. //上传文件存在判断
  20. if(empty($file['name'])){
  21. showMessage('请选择要上传csv的文件!','','html','error');
  22. }
  23. // 检查文件格式
  24. if ($file_type != 'csv') {
  25. showMessage('文件格式不对,请重新上传!','','html','error');
  26. exit;
  27. }
  28. $delimiter = trim($_POST['delimiter']);
  29. $importer = new car\importer($delimiter);
  30. //暂时屏蔽车型数据导入
  31. //$importer->run($file['tmp_name']);
  32. showMessage('操作完成,暂未开放' , urlAdmin('car_import', 'index'));
  33. return;
  34. }
  35. Tpl::showpage('car_import.index');
  36. }
  37. }