You are here

ActionUploadInit.php in N1ED - Visual editor as CKEditor plugin with Bootstrap support 7

File

vendor/edsdk/file-uploader-server-php/src/lib/action/ActionUploadInit.php
View source
<?php

/**
 * File Uploader Server package
 * Developer: N1ED
 * Website: https://n1ed.com/
 * License: GNU General Public License Version 3 or later
 **/
namespace EdSDK\FileUploaderServer\lib\action;

use EdSDK\FileUploaderServer\lib\action\resp\Message;
use EdSDK\FileUploaderServer\lib\action\resp\RespUploadInit;
use EdSDK\FileUploaderServer\lib\MessageException;
class ActionUploadInit extends AAction {
  public function getName() {
    return "uploadInit";
  }
  public function run($req) {
    $alphabeth = "abcdefghijklmnopqrstuvwxyz0123456789";
    do {
      $id = "";
      for ($i = 0; $i < 6; $i++) {
        $charNumber = rand(0, strlen($alphabeth) - 1);
        $id .= substr($alphabeth, $charNumber, 1);
      }
      $dir = $this->m_config
        ->getTmpDir() . "/" . $id;
    } while (file_exists($dir));
    if (!mkdir($dir)) {
      throw new MessageException(Message::createMessage(Message::UNABLE_TO_CREATE_UPLOAD_DIR));
    }
    return new RespUploadInit($id, $this->m_config);
  }

}

Classes

Namesort descending Description
ActionUploadInit