Exemple #1
0
 protected function processActionUpload()
 {
     static $uploader = null;
     if ($uploader === null) {
         $uploader = new \CFileUploader(array("events" => array("onFileIsUploaded" => array($this, "processActionHandleFile"))), "get");
     }
     $uploader->checkPost();
 }
 function getInstance($config = array())
 {
     if (null == self::$_instance) {
         self::$_instance = new self($config);
     }
     return self::$_instance;
 }
 function __construct($sFieldName, $sSaverName = 'FILE_UPLOADER', $maxW = 5000, $maxH = 5000, $maxSize = 50485780)
 {
     if (is_object($sFieldName) && $sFieldName instanceof CFileUploader) {
         //Конструктор копий
         parent::__construct($sFieldName->sField, $sFieldName->sSaverName);
     } else {
         parent::__construct($sFieldName, $sSaverName);
     }
     $this->iMaxSize = $maxSize;
     $this->iMaxWidth = $maxW;
     $this->iMaxHeight = $maxH;
     $this->sResizeMode = 'none';
 }
			"allowUpload" => "I",
			"events" => array("onFileIsUploaded" => array("CIMDisk", "UploadAvatar"))
		));
		if (!$CFileUploader->checkPost())
		{
			echo CUtil::PhpToJsObject(Array(
				'ERROR' => 'UPLOAD_ERROR'
			));
		}
	}
	else if ($_POST['IM_FILE_UPLOAD'] == 'Y')
	{
		CUtil::decodeURIComponent($_POST);
		$CFileUploader = new CFileUploader(array(
			"allowUpload" => "A",
			"events" => array(
				"onFileIsUploaded" => array("CIMDisk", "UploadFile")
			)
		));
		if (!$CFileUploader->checkPost())
		{
			echo CUtil::PhpToJsObject(Array(
				'ERROR' => 'UPLOAD_ERROR'
			));
		}
	}
	else if ($_POST['IM_FILE_REGISTER'] == 'Y')
	{
		$errorMessage = '';
		CUtil::decodeURIComponent($_POST);
		$_POST['FILES'] = CUtil::JsObjectToPhp($_POST['FILES']);
Exemple #5
0
 protected function processActionUploadFile()
 {
     static $uploader = null;
     if ($uploader === null) {
         $uploader = new \CFileUploader(array("events" => array("onFileIsUploaded" => array($this, "processActionHandleFile"))), "get");
     }
     if (!$uploader->checkPost() && check_bitrix_sessid() && $this->request->getFile("disk_file")) {
         $file = $this->request->getFile("disk_file") + array("files" => array("default" => $this->request->getFile("disk_file")));
         if ($this->processActionHandleFile($hash = "", $file, $package = array(), $upload = array(), $error = array())) {
             unset($file["files"]);
             unset($file["tmp_name"]);
             $this->sendJsonResponse(array('status' => self::STATUS_SUCCESS, 'data' => $file));
         } else {
             $this->sendJsonResponse(array('status' => self::STATUS_ERROR, 'message' => $error));
         }
     }
 }
 /**
  * метод перекрывает родительский, выполняет проверку попадания поля в список файловых полей и
  * обеспечивает сохранение значения файлового поля в случае необходимости
  * @param string
  * @param string
  * @param string
  * @param string
  * @return string
  */
 protected function _ParseField($prefix, $key, &$input, &$value)
 {
     global $KS_FS;
     $sResult = parent::_ParseField($prefix, $key, $input, $value);
     if (in_array($key, $this->arFileFields)) {
         $obUploadManager = new CFileUploader($prefix . $key, $this->sTable);
         if ($obUploadManager->IsReady()) {
             $sResult = $obUploadManager->Upload($this->sUploadPath . '/' . $this->_GenFileName($obUploadManager->GetFileName()), false);
             $obUploadManager->UploadDone();
             if ($sResult) {
                 if (!empty($input[$prefix . 'id']) && $input[$prefix . 'id'] != '') {
                     $arItem = $this->GetRecord(array('id' => $input[$prefix . 'id']));
                     if (is_array($arItem) && $arItem['id'] == $input[$prefix . 'id']) {
                         if (file_exists(UPLOADS_DIR . $arItem[$key]) && is_file(UPLOADS_DIR . $arItem[$key])) {
                             unlink(UPLOADS_DIR . $arItem[$key]);
                         }
                     }
                 }
             }
         }
         if (array_key_exists($prefix . $key . '_del', $_REQUEST)) {
             if ($input[$prefix . 'id'] != '') {
                 $arItem = $this->GetRecord(array('id' => $input[$prefix . 'id']));
                 if (is_array($arItem) && $arItem['id'] == $input[$prefix . 'id']) {
                     if (file_exists(UPLOADS_DIR . $arItem[$key])) {
                         unlink(UPLOADS_DIR . $arItem[$key]);
                     }
                 }
             }
             $sResult = "";
         }
     }
     return $sResult;
 }