You are here

public function FileUploaded::checkForErrors in N1ED - Visual editor as CKEditor plugin with Bootstrap support 7

Overrides AFile::checkForErrors

File

vendor/edsdk/file-uploader-server-php/src/lib/file/FileUploaded.php, line 31

Class

FileUploaded

Namespace

EdSDK\FileUploaderServer\lib\file

Code

public function checkForErrors($checkForExist) {
  if (!parent::checkForErrors($checkForExist)) {
    return false;
  }
  if ($this->m_newName !== $this
    ->getName() && !Utils::isFileNameSyntaxOk($this->m_newName)) {
    $this->m_commonErrors[] = Message::createMessage(Message::FILE_ERROR_SYNTAX, $this->m_newName);
  }
  if (Utils::isImage($this
    ->getName())) {
    $ext = $this
      ->getExt();
    $newExt = Utils::getExt($this->m_newName);
    if ($ext !== $newExt) {
      if (!($ext === "jpg" && $newExt === "jpeg") && !($ext === "jpeg" && $newExt === "jpg")) {
        $this->m_commonErrors[] = Message::createMessage(Message::FILE_ERROR_INCORRECT_IMAGE_EXT_CHANGE, $ext, $newExt);
      }
    }
  }
  return true;
}