123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- /**
- * FileSystem.php UTF-8
- *
- *
- * @date : 2019/8/9 9:46
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : luowei <lw@huosdk.com>
- * @version : HuoMp 1.0
- */
- namespace console\index\controller;
- use League\Flysystem\FileExistsException;
- use think\console\Input;
- use think\console\Output;
- use think\console\Command;
- class FileSystem extends Command {
- protected function configure() {
- $this->setName('filesystem')->setDescription('文件系统');
- }
- /**
- * @param Input $input
- * @param Output $output
- *
- * @return int|null|void
- */
- protected function execute(Input $input, Output $output) {
- try {
- $_filesystem = \FileSystem\FileSystem::create();
- //目录不存在会自动创建
- $_path = '/upload/qrcode/myimage.jpg';
- $_stream = fopen(ROOT_PATH.'image.jpg', 'r+');
- $_rs = $_filesystem->writeStream($_path, $_stream);
- var_dump($_rs);
- } catch (\Exception $_exception) {
- $_msg = 'file:'.$_exception->getFile().PHP_EOL.
- 'line:'.$_exception->getLine().PHP_EOL.
- 'msg:'.$_exception->getMessage();
- echo $_msg;
- }
- }
- }
|