public function uploadchildrenofindexAction()
 {
     die('finished -|-_-|-');
     try {
         $file_path = './comment/childrenOfIndexComment.xlsx';
         set_time_limit(0);
         $childHandler = new ExcelUpload($file_path);
         $data = $childHandler->handleChildComment();
         $dbHandle = new DBHandle();
         $dbHandle->insertChildIndexComment($data);
         echo 'finished';
     } catch (Exception $e) {
         echo $e->getMessage();
         return false;
     }
 }
Esempio n. 2
0
 public function __construct($file_path)
 {
     require_once "../app/classes/PHPExcel.php";
     #将单元格序列化后再进行Gzip压缩,然后保存在内存中
     PHPExcel_Settings::setCacheStorageMethod(PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip);
     $file_type = PHPExcel_IOFactory::identify($file_path);
     $objReader = PHPExcel_IOFactory::createReader($file_type);
     self::$objPHPExcel = $objReader->load($file_path);
 }
Esempio n. 3
0
 public function uploadleaderAction()
 {
     #严格json格式{ '···' : '···'},json_encode 无法实现
     try {
         $file_path = null;
         if ($this->request->hasFiles()) {
             foreach ($this->request->getUploadedFiles() as $file) {
                 if (empty($file->getName())) {
                     echo "{'error':'上传文件不能为空'}";
                     return;
                 } else {
                     $file_name = null;
                     $file_name .= date("Y_m_d_H_i_s_");
                     $file_name .= rand(1, 200) . "_";
                     $file_name .= $file->getName();
                     $file_path = "./upload/";
                     $file_path .= $file_name;
                     $file->moveTo($file_path);
                 }
             }
         } else {
             echo "{'error':'wrong to here'}";
             return;
         }
         if (empty($file_path)) {
             echo "{'error':'文件上传失败'}";
             return;
         }
         $excelHander = new ExcelUpload($file_path);
         $data = $excelHander->handleIL();
         if (file_exists($file_path)) {
             unlink($file_path);
         }
         $manager = $this->session->get('Manager');
         if (empty($manager)) {
             echo "{'error':'用户信息获取失败,请重新登陆'}";
             return;
         }
         $project_id = $manager->project_id;
         PmDB::insertLeader($data, $project_id);
         echo "{'success':'true'}";
         return;
     } catch (Exception $e) {
         if (file_exists($file_path)) {
             unlink($file_path);
         }
         $msg = $e->getMessage();
         echo "{'error':'{$msg}'}";
         return;
     }
 }