//1mb or less $upload->set_acceptable_types(array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png')); // comma separated string, or array //$upload->set_max_image_size(600, 600); $upload->set_overwrite_mode(1); $cf = new CompanyFactory(); $cf->cleanStoragePath($current_company->getId()); $dir = $cf->getStoragePath($current_company->getId()); break; case 'license': $upload->set_max_filesize(20000); //1mb or less $upload->set_acceptable_types(array('text/plain', 'plain/text', 'application/octet-stream')); // comma separated string, or array $upload->set_overwrite_mode(1); $dir = Environment::getStorageBasePath() . DIRECTORY_SEPARATOR . 'license' . DIRECTORY_SEPARATOR . $current_company->getId(); break; } Debug::Text('bUpload... Object Type: ' . $object_type, __FILE__, __LINE__, __METHOD__, 10); if (isset($dir)) { @mkdir($dir, 0700, TRUE); $upload_result = $upload->upload("userfile", $dir); //var_dump($upload ); //file data if ($upload_result) { $success = $upload_result . ' ' . TTi18n::gettext('Successfully Uploaded'); } else { $error = $upload->get_error(); } } Debug::Text('cUpload... Object Type: ' . $object_type, __FILE__, __LINE__, __METHOD__, 10); switch ($object_type) {
function getStoragePath($company_id = NULL) { if ($company_id == '') { $company_id = $this->getID(); } if ($company_id == '') { return FALSE; } return Environment::getStorageBasePath() . DIRECTORY_SEPARATOR . 'company_logo' . DIRECTORY_SEPARATOR . $company_id; }
function getStoragePath($company_id = NULL, $punch_id = NULL) { if ($company_id == '' and is_object($this->getPunchControlObject()) and is_object($this->getPunchControlObject()->getUserDateObject()) and is_object($this->getPunchControlObject()->getUserDateObject()->getUserObject())) { $company_id = $this->getPunchControlObject()->getUserDateObject()->getUserObject()->getCompany(); } if ($punch_id == '') { $punch_id = $this->getID(); } if ($company_id == '') { return FALSE; } if ($punch_id == '') { return FALSE; } $hash = crc32($company_id . $punch_id); $hash_dir[0] = substr($hash, 0, 2); $hash_dir[1] = substr($hash, 2, 2); $hash_dir[2] = substr($hash, 4, 2); return Environment::getStorageBasePath() . DIRECTORY_SEPARATOR . 'punch_images' . DIRECTORY_SEPARATOR . $company_id . DIRECTORY_SEPARATOR . $hash_dir[0] . DIRECTORY_SEPARATOR . $hash_dir[1] . DIRECTORY_SEPARATOR . $hash_dir[2]; }