FileSystem.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * FileSystem.php UTF-8
  4. *
  5. *
  6. * @date : 2019/8/9 9:46
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HuoMp 1.0
  11. */
  12. namespace console\index\controller;
  13. use League\Flysystem\FileExistsException;
  14. use think\console\Input;
  15. use think\console\Output;
  16. use think\console\Command;
  17. class FileSystem extends Command {
  18. protected function configure() {
  19. $this->setName('filesystem')->setDescription('文件系统');
  20. }
  21. /**
  22. * @param Input $input
  23. * @param Output $output
  24. *
  25. * @return int|null|void
  26. */
  27. protected function execute(Input $input, Output $output) {
  28. try {
  29. $_filesystem = \FileSystem\FileSystem::create();
  30. //目录不存在会自动创建
  31. $_path = '/upload/qrcode/myimage.jpg';
  32. $_stream = fopen(ROOT_PATH.'image.jpg', 'r+');
  33. $_rs = $_filesystem->writeStream($_path, $_stream);
  34. var_dump($_rs);
  35. } catch (\Exception $_exception) {
  36. $_msg = 'file:'.$_exception->getFile().PHP_EOL.
  37. 'line:'.$_exception->getLine().PHP_EOL.
  38. 'msg:'.$_exception->getMessage();
  39. echo $_msg;
  40. }
  41. }
  42. }