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.

66 lines
1.9 KiB

8 years ago
  1. <?php
  2. /**
  3. * 上传附件和上传视频
  4. * User: Jinqn
  5. * Date: 14-04-09
  6. * Time: 上午10:17
  7. */
  8. include "Uploader.class.php";
  9. /* 上传配置 */
  10. $base64 = "upload";
  11. switch (htmlspecialchars($_GET['action'])) {
  12. case 'uploadimage':
  13. $config = array(
  14. "pathFormat" => $CONFIG['imagePathFormat'],
  15. "maxSize" => $CONFIG['imageMaxSize'],
  16. "allowFiles" => $CONFIG['imageAllowFiles']
  17. );
  18. $fieldName = $CONFIG['imageFieldName'];
  19. break;
  20. case 'uploadscrawl':
  21. $config = array(
  22. "pathFormat" => $CONFIG['scrawlPathFormat'],
  23. "maxSize" => $CONFIG['scrawlMaxSize'],
  24. "allowFiles" => $CONFIG['scrawlAllowFiles'],
  25. "oriName" => "scrawl.png"
  26. );
  27. $fieldName = $CONFIG['scrawlFieldName'];
  28. $base64 = "base64";
  29. break;
  30. case 'uploadvideo':
  31. $config = array(
  32. "pathFormat" => $CONFIG['videoPathFormat'],
  33. "maxSize" => $CONFIG['videoMaxSize'],
  34. "allowFiles" => $CONFIG['videoAllowFiles']
  35. );
  36. $fieldName = $CONFIG['videoFieldName'];
  37. break;
  38. case 'uploadfile':
  39. default:
  40. $config = array(
  41. "pathFormat" => $CONFIG['filePathFormat'],
  42. "maxSize" => $CONFIG['fileMaxSize'],
  43. "allowFiles" => $CONFIG['fileAllowFiles']
  44. );
  45. $fieldName = $CONFIG['fileFieldName'];
  46. break;
  47. }
  48. /* 生成上传实例对象并完成上传 */
  49. $up = new Uploader($fieldName, $config, $base64);
  50. /**
  51. * 得到上传文件所对应的各个参数,数组结构
  52. * array(
  53. * "state" => "", //上传状态,上传成功时必须返回"SUCCESS"
  54. * "url" => "", //返回的地址
  55. * "title" => "", //新文件名
  56. * "original" => "", //原始文件名
  57. * "type" => "" //文件类型
  58. * "size" => "", //文件大小
  59. * )
  60. */
  61. /* 返回数据 */
  62. return json_encode($up->getFileInfo());