EOF; return $html; } /** * 单个图片上传 * @param $folder * @param string $position * @param array $option */ public function single($id, $name = "data[image]", $file = '') { $url = U("/Base/Photos/index"); $imgHtml = ""; if (!empty($file)) { $imgHtml .= "
"; } $idbutton = $id . '_button'; $html = <<
$imgHtml
EOF; return $html; } public function single2($id, $name = "data[image]", $file = "", $folder, $option = []) { $folder = urlencode($folder); $position = isset($option['position']) ? $option['position'] : 'local'; $option['width'] = isset($option['width']) ? $option['width'] : ""; $option['height'] = isset($option['height']) ? $option['height'] : ""; $maxFileSize = isset($option['maxSize']) ? $option['maxSize'] : 10 * 1024; $filename = explode('/', $file); $filename = end($filename); $class = isset($option['class']) ? $option['class'] : 1; $token = csrf_token(); $html = <<
EOF; return $html; } /** * 统一多张图片 * @param $folder * @param $id * @param string $name * @param array $imgs * @param null $callBackFun * @return string */ public function multi($id, $name = "data[image]", $files = [], $option = []) { $url = U("/Base/Photos/index"); $maxCount = isset($option['maxCount']) ? $option['maxCount'] : 0; $name = $name . '[]'; $imgHtml = ""; if (!empty($files)) { foreach ($files as $file) { $imgHtml .= "
"; } } $idbutton = $id . '_button'; $html = <<
$imgHtml
EOF; return $html; } public function multi2($id, $name = "image", $files = "", $folder, $option = []) { $folder = urlencode($folder); $position = isset($option['position']) ? $option['position'] : 'local'; $option['width'] = isset($option['width']) ? $option['width'] : ""; $option['height'] = isset($option['height']) ? $option['height'] : ""; $maxFileSize = isset($option['maxSize']) ? $option['maxSize'] : 10 * 1024; $maxCount = isset($option['maxCount']) ? $option['maxCount'] : 0; $class = isset($option['class']) ? $option['class'] : 1; $imgHtml = ""; $preview = json_encode($files); $caps = []; foreach ($files as $k => $file) { $caps[$k]['caption'] = $file; $caps[$k]['url'] = "/admin/Base/AttachmentInfo/remove?file=" . $file; } $caps = json_encode($caps); $token = csrf_token(); foreach ($files as $file) { $imgHtml .= ""; } $html = <<
$imgHtml EOF; return $html; } }