It will attach the file.

@param $id
@param $table
@param \Symfony\Component\HttpFoundation\File\UploadedFile $file
183478
public function attachFile($id, $table, \Symfony\Component\HttpFoundation\File\UploadedFile $file)
    {
        $newFileName = md5(microtime() . '.' . strtolower($file->getClientOriginalExtension()));
        $relativePath = $table . '/' . date('Y/m/d');
        $relativeFilePath = $relativePath . '/' . $newFileName;
        $dstPath = APP_UPLOADS_DIR . '/' . $relativePath;
        $file->move($dstPath, $newFileName);
        $pic = new \Towel\Model\Pic();

        $pic->object_id = $id;
        $pic->object_type = $table;
        $pic->pic = $relativeFilePath;
        $pic->created = time();
        $pic->save();
    }
899483
public function insert(Table $table, $row)
    {
        $end = $this->startCommandTimer();
        $this->writeCommand('insert', [$table->getName()]);
        parent::insert($table, $row);
        $end();
    }
275776
protected function upload(UploadedFile $file)
    {
        $this->renameIfExists($file);

        if (!is_null($this->storage_permission)) {
            return $this->storage->putFileAs($this->getDirectory(), $file, $this->name, $this->storage_permission);
        }

        return $this->storage->putFileAs($this->getDirectory(), $file, $this->name);
    }
1111697
public function set(string $name, UploadedFileInterface $uploadedFile): void
    {
        $this->uploadedFiles[$name] = $uploadedFile;
    }
151568
protected function addFile(File $file) {
        $files = $this->getFiles();
        $files[$file->getName()] = $file;
        $this->setFiles($files);
    }
873117
public function log($file, $version)
	{
		$record = array('migration' => $file, 'version' => $version);

		$this->table()->insert($record);
	}
423335
public function delete(string $table, string $id): bool
    {
        return $this->deleteWhere($table, 'id', $id);
    }
972925
public function delete($table = '', $id = '')
    {
        $sql = 'DELETE FROM '.$table.' WHERE id='.$id;
        echo $sql.'<br/>';
        return $this->execute($sql);
    }
790836
public function upload($id, array $files)
    {
        foreach ($files as $file) {
            if ($file instanceof FileEntity) {
                foreach ($this->dimensions as $index => $dimension) {

                    $width = (int) $dimension[0];
                    $height = (int) $dimension[1];

                    $destination = $this->makeDestination($id, $width, $height);

                    // Ensure that destination actually exists
                    if (!is_dir($destination)) {
                        mkdir($destination, 0777, true);
                    }

                    $to = sprintf('%s/%s', $destination, $file->getUniqueName());

                    $imageProcessor = new ImageProcessor($file->getTmpName());
                    $imageProcessor->thumb($width, $height);

                    // This might fail sometimes
                    $imageProcessor->save($to, $this->quality);
                }
            }
        }

        return true;
    }
565121
public function deleteById($table, $id, $id_col = 'id')
    {
        $options = array(
            'W' => '`' . $id_col . "`='" . $this->escape($id) . "'",
            'L' => '1',
        );
        return $this->delete($table, $options);
    }
63752
public function delete($id)
    {
        $files = glob($this->getFilename($id));

        if (count($files)) {
            array_map('unlink', $files);
        }
    }
736886
protected function setFile($file_id)
    {
        $this->data_file = array();

        if (is_numeric($file_id)) {

            $conditions = array(
                'language' => 'und',
                'file_id' => $file_id
            );

            $this->data_file = $this->file->get($conditions);

            if (empty($this->data_file)) {
                $this->outputHttpStatus(404);
            }

            $this->prepareFile($this->data_file);
        }
    }
358120
protected function _move(Table $table, $id, $step = 1, $type = self::TYPE_UP)
    {
        $behaviors = $table->behaviors();
        if (!Arr::in('Tree', $behaviors->loaded())) {
            $behaviors->load('Tree');
        }

        $entity = $table->get($id);

        /** @var TreeBehavior $treeBehavior */
        $treeBehavior = $behaviors->get('Tree');
        $treeBehavior->setConfig('scope', $entity->get('id'));

        if ($table->{$type}($entity, $step)) {
            $this->Flash->success($this->_configRead('messages.success'));
        } else {
            $this->Flash->error($this->_configRead('messages.error'));
        }

        return $this->_redirect();
    }
95682
public function upload(\Symfony\Component\HttpFoundation\File\UploadedFile $file) {
    
    // We simply move the uploaded file to the target directory
    $result = $file->move(\Config::get('plupload::plupload.upload_dir'), $file->getClientOriginalName());

    // Return the result of the upload
    return $this->respond(array('OK' => ($result) ? 1 : 0));
  }
142559
protected function attachFile($file)
    {
        $dms = DMS::inst();
        $record = $this->getRecord();

        if ($record instanceof DMSDocument) {
            // If the edited record is a document,
            // assume we're replacing an existing file
            $doc = $record;
            $doc->ingestFile($file);
        } else {
            // Otherwise create it
            $doc = $dms->storeDocument($file);
            $file->delete();
        }

        // Relate to the underlying document set being edited.
        // Not applicable when editing the document itself and replacing it, or uploading from the ModelAdmin
        if ($record instanceof DMSDocumentSet) {
            $record->Documents()->add($doc, array('ManuallyAdded' => 1));
        }

        return $doc;
    }
939962
public function deleteTable($id)
    {
        if (isset($this[$id])) {
            Common::destroy($this[$id]);
            $this->setTableDeleted($id);
        }
    }
824767
public function actionShowFile(string $id): void
	{
		$response = $this->app->logs->getFile($id);
		if ($response) {
			$this->sendResponse($response);
		} else {
			$this->error();
		}
	}