如何用ThinkPHP3.2实现基于Layui的文件上传接口?

2026-04-03 04:461阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计182个文字,预计阅读时间需要1分钟。

如何用ThinkPHP3.2实现基于Layui的文件上传接口?

ThinkPHP3.2为layui编写的上传接口+3145728,文件上传的最大文件大小(以字节为单位),0为不限制大小。保存路径为/Content/,根路径为/Upload/Content/,保存根路径+文件名+扩展名。文件名由uniqid生成。

如何用ThinkPHP3.2实现基于Layui的文件上传接口?

thinkphp3.2给layui写的上传接口

3145728,//文件上传的最大文件大小(以字节为单位),0为不限大小 // 'savePath' => '/Content/', 'rootPath' => 'Upload/Content/', //保存根路径 'saveName' => array('uniqid',''), 'exts' => array('jpg', 'gif', 'png', 'jpeg'), 'autoSub' => true, 'subName' => array('date','Ymd'), ); $upload=new Upload($config); $info=$upload->upload(); if ($info){ foreach($info as $file){ $data['src']="/".$config['rootPath'].$file['savepath'].$file['savename']; } $this->toApi('0',"上传成功",$data); }else{ $this->toApi('1',$upload->getError()); } } }

标签:上传接口T

本文共计182个文字,预计阅读时间需要1分钟。

如何用ThinkPHP3.2实现基于Layui的文件上传接口?

ThinkPHP3.2为layui编写的上传接口+3145728,文件上传的最大文件大小(以字节为单位),0为不限制大小。保存路径为/Content/,根路径为/Upload/Content/,保存根路径+文件名+扩展名。文件名由uniqid生成。

如何用ThinkPHP3.2实现基于Layui的文件上传接口?

thinkphp3.2给layui写的上传接口

3145728,//文件上传的最大文件大小(以字节为单位),0为不限大小 // 'savePath' => '/Content/', 'rootPath' => 'Upload/Content/', //保存根路径 'saveName' => array('uniqid',''), 'exts' => array('jpg', 'gif', 'png', 'jpeg'), 'autoSub' => true, 'subName' => array('date','Ymd'), ); $upload=new Upload($config); $info=$upload->upload(); if ($info){ foreach($info as $file){ $data['src']="/".$config['rootPath'].$file['savepath'].$file['savename']; } $this->toApi('0',"上传成功",$data); }else{ $this->toApi('1',$upload->getError()); } } }

标签:上传接口T