截流自动化的商城平台
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.

Local.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\common\server\storage\engine;
  3. /**
  4. * 本地文件驱动
  5. * Class Local
  6. * @package app\common\library\storage\drivers
  7. */
  8. class Local extends Server
  9. {
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. }
  14. /**
  15. * 上传
  16. * @param $save_dir (保存路径)
  17. * @return bool
  18. */
  19. public function upload($save_dir)
  20. {
  21. // 验证文件并上传
  22. $info = $this->file->move($save_dir, $this->fileName);
  23. if (empty($info)) {
  24. $this->error = $this->file->getError();
  25. return false;
  26. }
  27. return true;
  28. }
  29. public function fetch($url, $key=null) {}
  30. /**
  31. * 删除文件
  32. * @param $fileName
  33. * @return bool|mixed
  34. */
  35. public function delete($fileName)
  36. {
  37. // 文件所在目录
  38. $filePath = public_path() . "/{$fileName}";
  39. return !file_exists($filePath) ?: unlink($filePath);
  40. }
  41. /**
  42. * 返回文件路径
  43. * @return mixed
  44. */
  45. public function getFileName()
  46. {
  47. return $this->fileName;
  48. }
  49. }