/** * Upload file * @param string $path * @return string */ public function uploadAction() { $maxUploadSize = str_replace('m', '000000', strtolower(ini_get('upload_max_filesize'))); try { $allowedExts = implode(',', array_keys(\app::$config['ext'])); $upload = new \core\classes\upload($maxUploadSize, $allowedExts, PROFILE_PATH . $this->entity->getModule() . '/' . $this->path . '/'); $result = $upload->upload($_FILES['fileField']); } catch (\Exception $exc) { \app::$response->setHeader('X-XSS-Protection', '0'); \app::$response->setHeader('Content-type', 'application/json'); if (ob_get_level()) { ob_clean(); } return json_encode(array('eval' => '', 'notification' => $exc->getMessage(), 'notificationType' => 'negative')); } if ($result !== FALSE) { $arr = $_FILES['fileField']; $arr['name'] = $result; unset($arr['tmp_name']); \app::$response->setHeader('Content-type', 'application/json'); return json_encode($arr); } else { return FALSE; } }
/** * Upload file * @param string $path * @return string */ protected function uploadAction($path, $size = 104857600, $allowedExt = 'image') { try { $upload = new \core\classes\upload($size, $allowedExt, $path . '/'); $result = $upload->upload($_FILES['fileField']); } catch (\Exception $exc) { $return = array('notification' => $exc->getMessage(), 'notificationType' => 'negative'); return $this->returnResult($return); } if ($result !== FALSE) { $arr = $_FILES['fileField']; $arr['name'] = $result; $params = @getimagesize($path . '/' . $result); list($width, $height, $type, $attr) = $params; if ($params) { $arr['x'] = $width; $arr['y'] = $height; $arr['type'] = $type; } unset($arr['tmp_name']); \app::$response->setHeader('Content-type', 'application/json'); return json_encode($arr); } else { return FALSE; } }
/** * Upload file * @param string $path * @return string */ public function uploadAction() { $maxUploadSize = str_replace('m', '000000', strtolower(ini_get('upload_max_filesize'))); try { $upload = new \core\classes\upload($maxUploadSize, 'image', PROFILE_PATH . $this->entity->getModule() . '/' . $this->path . '/'); $result = $upload->upload($_FILES['fileField']); } catch (\Exception $exc) { \app::$response->setHeader('X-XSS-Protection', '0'); \app::$response->setHeader('Content-type', 'application/json'); if (ob_get_level()) { ob_clean(); } return json_encode(array('eval' => '', 'notification' => $exc->getMessage(), 'notificationType' => 'negative')); } if ($result !== FALSE) { $arr = $_FILES['fileField']; $arr['name'] = $result; $params = @getimagesize($path . '/' . $result); list($width, $height, $type, $attr) = $params; if ($params) { $arr['x'] = $width; $arr['y'] = $height; $arr['type'] = $type; } unset($arr['tmp_name']); \app::$response->setHeader('Content-type', 'application/json'); return json_encode($arr); } else { return FALSE; } }