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.

function.php 570 B

3 years ago
12345678910111213141516171819
  1. <?php
  2. function upload(){
  3. $upload = new \Think\Upload();// 实例化上传类
  4. $upload->maxSize = 3145728 ;// 设置附件上传大小
  5. $upload->exts = array('xls', 'xlsx');// 设置附件上传类型
  6. $upload->rootPath='./Public/';
  7. $upload->savePath = './Uploads/'; // 设置附件上传目录
  8. // 上传单个文件
  9. $info = $upload->uploadOne($_FILES['importFile']);
  10. if(!$info) {
  11. $return=array(0,$upload->getError());
  12. }else {
  13. $path='./Public/'.$info['savepath'].$info['savename'];
  14. $return=array(1,$path);
  15. }
  16. return $return;
  17. }