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.

43 lines
1.0 KiB

  1. <?php
  2. namespace backend\logic\file;
  3. use common\models\ars\TemFile;
  4. class FileManager
  5. {
  6. public static $extension = [
  7. TemFile::TYPE_IMAGE => ['jpg', 'png', 'jpeg'],
  8. TemFile::TYPE_VIDEO => ['mp4'],
  9. TemFile::TYPE_EXCEL => [],
  10. TemFile::TYPE_WORD => ['docx'],
  11. TemFile::TYPE_TXT => ['txt'],
  12. ];
  13. /**
  14. * @param $array
  15. * @param $value
  16. * @param int $key
  17. * @return int
  18. * 查看$extension数组中是否存在文件类型,不存在则返回-1
  19. */
  20. public function searchType($array,$value, $key=-1){
  21. foreach($array as $k=>$row){
  22. if(!is_array($row)){
  23. if($row == $value){
  24. if($key != -1) {
  25. return $key;
  26. }else{
  27. return -1;
  28. }
  29. }
  30. }else{
  31. $r = self::searchType($row,$value, $k);
  32. if($r != -1){
  33. return $r;
  34. }
  35. }
  36. }
  37. return -1;
  38. }
  39. }