wei7815
/**
* uploasImg
* 私有方法 上传多张保存图片
* User:wangwei
* @param $name string 上传的图片文件名
* @return array [error_code,error_msg,path]
*/
private function uploadImg($name)
{
if (is_array($name)) {
$imgs = [];
//获取表单上传文件
$files = $this->request->file($name);
foreach ($files as $file) {
//移动到框架应用根目录/public/uploads/目录下
$info = $file->rule(\'uniqid\')->move(ROOT_PATH . \'public\' . DS . \'uploads\' . DS . \'ads\');
if ($info) {
// 成功上传后 获取上传信息
//输出 jpg
$imgs[] = \'/uploads/ads/\'.$info->getFilename();

} else {
echo $file->getError();
}
}
} else {
$imgs = \'\';
$files = $this->request->file($name);
$info = $files->rule(\'uniqid\')->move(ROOT_PATH . \'public\' . DS . \'uploads\' . DS . \'ads\');
if ($info) {
// 成功上传后 获取上传信息
//输出 jpg
$imgs[] = \'/uploads/ads/\'.$info->getFilename();

} else {
echo $files->getError();
}
}

return [\'error_code\' => 0, \'error_msg\' => \'\', \'name\' => $imgs];
}

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
猜你喜欢
  • 2021-11-23
  • 2021-05-16
  • 2021-08-05
  • 2021-11-17
  • 2022-01-16
  • 2022-01-02
  • 2022-01-23
相关资源
相似解决方案