You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://doc.hyperf.io
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace App\Controller;
  12. use Hyperf\HttpServer\Annotation\AutoController;
  13. use League\Flysystem\Filesystem;
  14. /**
  15. * @AutoController()
  16. * @package App\Controller
  17. */
  18. class IndexController extends AbstractController
  19. {
  20. public function index()
  21. {
  22. $user = $this->request->input('user', 'Hyperf');
  23. $method = $this->request->getMethod();
  24. return [
  25. 'method' => $method,
  26. 'message' => floatval(2.00),
  27. ];
  28. }
  29. public function example(Filesystem $filesystem)
  30. {
  31. $file = $this->request->file('upload');
  32. var_dump($file);die;
  33. $fileContent = file_get_contents($file->getRealPath());
  34. var_dump($fileContent);die;
  35. $stream = fopen($file->getRealPath(),'r+');
  36. $filesystem->writeStream('uplaods/'.$file->getClientFilename(),$stream);
  37. fclose($stream);
  38. }
  39. }