public function actionInfoImport() { $productId = $_REQUEST['product_id']; $infoType = $_REQUEST['type']; $productModuleId = $_REQUEST['productmodule_id']; $error = ""; $msg = ""; $fileElementName = 'casefilename'; $fileCheckResult = $this->checkFileBeforeImport(); if ('' != $fileCheckResult) { echo json_encode(array('msg' => $fileCheckResult)); return; } $fileName = $_FILES[$fileElementName]['tmp_name']; $fileSize = filesize($fileName); if (CommonService::getMaxFileSize() < $fileSize) { echo json_encode(array('msg' => Yii::t('Common', 'Max file size exceeded'))); return; } $importService = new ImportService(); $msg = $importService->import($fileName, $productId, $infoType, $productModuleId); echo json_encode(array('error' => '', 'msg' => $msg)); @unlink($_FILES[$fileElementName]); }
/** * @param string $file * @param integer $pid * @param integer $category * @param boolean $truncate */ public function importCommand($file, $pid, $category = NULL, $truncate = FALSE) { $importService = new ImportService(); $importService->import($file, $pid, $category, $truncate); }