加载上传文件
@return bool
504670
public function beforeValidate()
    {
        $this->id_file = UploadedFile::getInstance($this, 'id_file');
        $this->id_file1 = UploadedFile::getInstance($this, 'id_file1');
        $this->id_file2 = UploadedFile::getInstance($this, 'id_file2');
        return parent::beforeValidate();
    }
275589
public function newUpload()
    {
        if (null === $this->getFile()) {
            return null;
        }

        $this->moveFile();

        return $this->getUploadRootDir() . $this->path;
    }
685844
public function install() {
		if (file_exists(__DIR__.'/../../../../../../mouf/no_commit/MoufUsers.php')) {
			$this->contentBlock->addFile(dirname(__FILE__)."/../../views/mouf_installer/moufusers_exists.php", $this);
			$this->template->toHtml();
			return;
		}
		
		$oldUmask = umask();
		umask(0);
		
		// Now, let's write the basic Mouf files:
		if (!file_exists(__DIR__."/../../../../../../mouf")) {
			mkdir(__DIR__."/../../../../../../mouf", 0775);
		}
		if (!file_exists(__DIR__."/../../../../../../mouf/no_commit")) {
			mkdir(__DIR__."/../../../../../../mouf/no_commit", 0775);
		}
		
		
		// Write Mouf.php (always):
		//if (!file_exists(__DIR__."/../../../../../../mouf/Mouf.php")) {
			$moufStr = "<?php
define('ROOT_PATH', realpath(__DIR__.'/..').DIRECTORY_SEPARATOR);
require_once __DIR__.'/../config.php';
if (defined('ROOT_URL')) {
	define('MOUF_URL', ROOT_URL.'vendor/mouf/mouf/');
}
		
require_once __DIR__.'/../vendor/autoload.php';
		
require_once 'MoufComponents.php';
?>";
		
			file_put_contents(__DIR__."/../../../../../../mouf/Mouf.php", $moufStr);
			// Change rights on Mouf.php, but ignore errors (the file might be writable but still belong to someone else).
			@chmod(__DIR__."/../../../../../../mouf/Mouf.php", 0664);
		//}
		
		
		
		// Write MoufComponents.php:
		if (!file_exists(__DIR__."/../../../../../../mouf/MoufComponents.php")) {
			$moufComponentsStr = "<?php
/**
 * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten.
 */
		
use Mouf\MoufManager;
MoufManager::initMoufManager();
\$moufManager = MoufManager::getMoufManager();
		
?>";
		
			file_put_contents(__DIR__."/../../../../../../mouf/MoufComponents.php", $moufComponentsStr);
			chmod(__DIR__."/../../../../../../mouf/MoufComponents.php", 0664);
		}
		
		// Finally, let's generate the MoufUI.php file:
		if (!file_exists(__DIR__."/../../../../../../mouf/MoufUI.php")) {
			$moufUIStr = "<?php
/**
 * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten.
 */
		
	?>";
		
			file_put_contents(__DIR__."/../../../../../../mouf/MoufUI.php", $moufUIStr);
			chmod(__DIR__."/../../../../../../mouf/MoufUI.php", 0664);
		}
		
		// Finally 2, let's generate the config.php file:
		if (!file_exists(__DIR__."/../../../../../../config.php")) {
			$moufConfig = "<?php
/**
 * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten.
 * Use the UI to edit it instead.
 */
		
?>";
		
			file_put_contents(__DIR__."/../../../../../../config.php", $moufConfig);
			chmod(__DIR__."/../../../../../../config.php", 0664);
		}
		
		// Finally 3 :), let's generate the MoufUsers.php file:
		if (!file_exists(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php")) {
			$moufConfig = "<?php
/**
 * This contains the users allowed to access the Mouf framework.
 */
\$users[".var_export(userinput_to_plainstring($_REQUEST['login']), true)."] = array('password'=>".var_export(sha1(userinput_to_plainstring($_REQUEST['password'])), true).", 'options'=>null);
		
?>";
		
			file_put_contents(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php", $moufConfig);
			chmod(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php", 0664);
		}
		
		umask($oldUmask);
		
		header("Location: ".ROOT_URL);
		
		
	}
702508
public function setupDrupalFilesystem()
    {
        $this->taskFilesystemStack()
            ->chmod($this->sitesPath, 0775, 0000, true)
            ->mkdir("{$this->sitesPath}/default/files", 0775, true)
            ->run();

        if ($this->getProjectVersion() >= 8) {
            $install_path = $this->getInstallPath();

            $this->taskFilesystemStack()
                ->mkdir("{$install_path}/profiles/custom", 0775, true)
                ->mkdir("{$install_path}/modules/custom", 0775, true)
                ->mkdir("{$install_path}/modules/contrib", 0775, true)
                ->run();
        }

        return $this;
    }
640207
protected function uploadFile () : bool
	{
		// Determine the destination
		$this->newFileLocation = $this->getUploadDir().$this->uploadFileDir.getConstant('DS', TRUE).$this->newFileName;			  
		// Make sure a file doesn't already exist in the target location
		if (file_exists($this->newFileLocation)):
			$this->error = "The file {$this->newFileLocation} already exists.";
			return FALSE;
		endif;
		// Attempt to move/upload the file 
		if (!move_uploaded_file($this->tempPath, $this->newFileLocation)):
			// File was not moved - failure.
			$this->error = "The file upload failed.";
			return FALSE;
		endif;
		// SUCCESS
		return TRUE;
	}
25894
public function install()
    {
        if (! isset($this->complement['installation-files'])) {
            self::$errors[] = [
                'message' => $this->complement['path']['root']
            ];

            return false;
        }

        $this->deleteDirectory();
        $this->changeState();

        $installed = $this->installComplement(
            $this->complement['installation-files'],
            $this->complement['path']['root'],
            $this->complement['slug']
        );

        if ($installed) {
            self::load(
                $this->complement['config-file'],
                $this->complement['path']['root']
            );

            $this->changeState();

            return true;
        }

        return false;
    }
106358
private function setFileAction()
    {
        array_push($this->actions, 'file');

        $this->addForm = array_diff($this->addForm, ['files']);
        $this->editForm = array_diff($this->addForm, ['files']);

        $this->setModelDefaults('files', []);
        $this->setColumnFormat('files', 'files');

        return $this;
    }
803078
public function add()
    {
        $translation = $this->Translations->newEntity();
        if ($this->request->is('post')) {
            $data = is_array($this->request->getData()) ? $this->request->getData() : [];
            $translation = $this->Translations->patchEntity($translation, $data);
            $result = $this->Translations->save($translation);
            if ($result) {
                $this->Flash->success((string)__('The translation has been saved.'));

                return $this->redirect(['action' => 'index']);
            }
            $this->Flash->error((string)__('The translation could not be saved. Please, try again.'));
        }
        $languages = $this->Translations->Languages->find('all', ['limit' => 200]);
        $this->set(compact('translation', 'languages'));
        $this->set('_serialize', ['translation']);
    }
528017
public function push()
    {
        // return the configurations from the config file
        $configurations = $this->helper->getConfigurations();

        // Initialize an instance of the asset holder to read the configurations
        // then call the read(), to return all the allowed assets as a collection of files objects
        $assets = $this->finder->read($this->asset_holder->init($configurations));

        // store the returned assets in the instance of the asset holder as collection of paths
        $this->asset_holder->setAssets($assets);

        // return an instance of the corresponding Provider concrete according to the configuration
        $provider = $this->provider_factory->create($configurations);

        return $provider->upload($this->asset_holder->getAssets());
    }
1281021
public function update()
        {
                $ok = true;

                // perform updates...
                $ok = $this->updateFile(self::FILENAME_RULES);

                if ($ok)
                        $ok = $this->updateFile(self::FILENAME_CONVERTER);

                return $ok;
        }
711698
public function upload()
    {
        $uploaded_files = request()->file('upload');
        $error_bag = [];
        $new_filename = null;

        foreach (is_array($uploaded_files) ? $uploaded_files : [$uploaded_files] as $file) {
            try {
                $new_filename = $this->lfm->upload($file);
            } catch (\Exception $e) {
                Log::error($e->getMessage(), [
                    'file' => $e->getFile(),
                    'line' => $e->getLine(),
                    'trace' => $e->getTraceAsString()
                ]);
                array_push($error_bag, $e->getMessage());
            }
        }

        if (is_array($uploaded_files)) {
            $response = count($error_bag) > 0 ? $error_bag : parent::$success_response;
        } else { // upload via ckeditor 'Upload' tab
            if (is_null($new_filename)) {
                $response = $error_bag[0];
            } else {
                $response = view(Lfm::PACKAGE_NAME . '::use')
                    ->withFile($this->lfm->setName($new_filename)->url());
            }
        }

        return $response;
    }
566252
public function add()
    {
        if ($this->request->is('post')) {
            
            $userGroupPermission = $this->UserGroupPermission->findUserGroupPermission(
                    ['id'], 
                    $this->request->data['group_or_user_id'], 
                    $this->request->data['group_or_user'], 
                    $this->request->data['permission_id']
                )->first();
            
            if(!is_null($userGroupPermission)) {
                $this->UserGroupPermission->get($userGroupPermission->id);
                $userGroupPermission->allow = $this->request->data['allow'];
            }else {
                $userGroupPermission = $this->UserGroupPermission->patchEntity($userGroupPermission, $this->request->data);
            }

            if ($this->UserGroupPermission->save($userGroupPermission)) {
                $this->Flash->success(__('The user group permission has been saved.'));
            } else {
                $this->Flash->error(__('The user group permission could not be saved. Please, try again.'));
            }
        }
        return $this->redirect(['action' => 'index']);
    }
687689
public function add()
    {
        if($moduleEvents = $this->module->events())
        {
            $systemEvents = $this->load();
            if(isset($moduleEvents['listen']))
            // for listen event we must check if exists merge if not add it
            foreach ($moduleEvents['listen'] as $event => $listens)
            {
                if(isset($systemEvents['listen'][$event]))
                    $systemEvents['listen'][$event] = array_merge($systemEvents['listen'][$event],$listens);
                else
                    $systemEvents['listen'][$event] = $listens;
            }
            // for subscribe
            if(isset($moduleEvents['subscribe']))
                $systemEvents['subscribe'][] = $moduleEvents['subscribe'];
            return $this->set($systemEvents);
        }
        return true;
    }
39118
public function uploadFile()
    {
        if (!$this->request->files->has('file')) {
            return false;
        }
        $file   = $this->request->files->get('file');
        $upload = rtrim($this->uploadDir, '/');
        if (!is_dir($upload)) {
            mkdir($upload, 0777, true);
        }
        $file->move(realpath($upload), $file->getClientOriginalName());

        return sprintf('/%s/%s', pathinfo($upload, PATHINFO_BASENAME),
            pathinfo($file->getClientOriginalName(), PATHINFO_BASENAME));
    }
585446
public function import() : bool
    {
        $files = glob($this->exportFolder . 'php/' . '*.php');

        if (empty($files)) {
            return false;
        }

        foreach ($files as $file) {
            $this->imported[] = $file;
            require_once $file;
        }

        return true;
    }
1094700
public function doUpload()
	{
		$mimes = $this->getOption('mimes') ? '|mimes:' . $this->getOption('mimes') : '';

		//use the multup library to perform the upload
		$result = Multup::open('file', 'max:' . $this->getOption('size_limit') * 1000 . $mimes, $this->getOption('location'),
									$this->getOption('naming') === 'random')
			->set_length($this->getOption('length'))
			->upload();

		return $result[0];
	}
1108737
public function add()
    {
        $this->dirs = array_merge($this->dirs, func_get_args());
        $this->dirs = array_filter($this->dirs);
        $this->dirs = array_values($this->dirs);
    }