|
|
@@ -89,6 +89,21 @@ class Images extends AuthController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function upload_by_url()
|
|
|
+ {
|
|
|
+ $url = $this->request->param('url');
|
|
|
+ $pid = $this->request->param('pid', session('pid'));
|
|
|
+ $upload_type = 5; //$this->request->get('upload_type', sys_config('upload_type', 1));
|
|
|
+ $fileInfo = getUrlImgInfo($url);
|
|
|
+ if ($fileInfo) {
|
|
|
+ $ok = SystemAttachmentModel::attachmentAdd($fileInfo['name'], $fileInfo['size'], $fileInfo['type'], $fileInfo['dir'], $fileInfo['thumb_path'], $pid, $upload_type, $fileInfo['time']);
|
|
|
+ if ($ok) {
|
|
|
+ return JsonService::successful('上传成功', ['src' => $url]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return JsonService::fail('上传失败');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* ajax 提交删除
|
|
|
*/
|
|
|
@@ -97,7 +112,7 @@ class Images extends AuthController
|
|
|
$request = app('request');
|
|
|
$post = $request->post();
|
|
|
if (empty($post['imageid']))
|
|
|
- Json::fail('还没选择要删除的图片呢?');
|
|
|
+ Json::fail('还没选择要删除的图片');
|
|
|
foreach ($post['imageid'] as $v) {
|
|
|
if ($v) self::deleteimganddata($v);
|
|
|
}
|
|
|
@@ -109,31 +124,42 @@ class Images extends AuthController
|
|
|
*/
|
|
|
public function deleteimganddata($att_id)
|
|
|
{
|
|
|
-
|
|
|
$attinfo = SystemAttachmentModel::get($att_id);
|
|
|
if ($attinfo) {
|
|
|
- try {
|
|
|
- $upload = new Upload((int)$attinfo['image_type'], [
|
|
|
- 'accessKey' => sys_config('accessKey'),
|
|
|
- 'secretKey' => sys_config('secretKey'),
|
|
|
- 'uploadUrl' => sys_config('uploadUrl'),
|
|
|
- 'storageName' => sys_config('storage_name'),
|
|
|
- 'storageRegion' => sys_config('storage_region'),
|
|
|
- ]);
|
|
|
- if ($attinfo['image_type'] == 1) {
|
|
|
- if (strpos($attinfo['att_dir'], '/') == 0) {
|
|
|
- $attinfo['att_dir'] = substr($attinfo['att_dir'], 1);
|
|
|
+ if ($attinfo['image_type'] > 0 && $attinfo['image_type'] < 5) {
|
|
|
+ try {
|
|
|
+ $upload = new Upload((int)$attinfo['image_type'], [
|
|
|
+ 'accessKey' => sys_config('accessKey'),
|
|
|
+ 'secretKey' => sys_config('secretKey'),
|
|
|
+ 'uploadUrl' => sys_config('uploadUrl'),
|
|
|
+ 'storageName' => sys_config('storage_name'),
|
|
|
+ 'storageRegion' => sys_config('storage_region'),
|
|
|
+ ]);
|
|
|
+ if ($attinfo['image_type'] == 1) {
|
|
|
+ if (strpos($attinfo['att_dir'], '/') == 0) {
|
|
|
+ $attinfo['att_dir'] = substr($attinfo['att_dir'], 1);
|
|
|
+ }
|
|
|
+ $upload->delete($attinfo['att_dir']);
|
|
|
+ } else {
|
|
|
+ $upload->delete($attinfo['name']);
|
|
|
}
|
|
|
- $upload->delete($attinfo['att_dir']);
|
|
|
- } else {
|
|
|
- $upload->delete($attinfo['name']);
|
|
|
+ } catch (\Throwable $e) {
|
|
|
}
|
|
|
- } catch (\Throwable $e) {
|
|
|
}
|
|
|
+
|
|
|
SystemAttachmentModel::where('att_id', $att_id)->delete();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function window_upload_by_url()
|
|
|
+ {
|
|
|
+ $formbuider = [];
|
|
|
+ $formbuider[] = Form::input('url', 'url');
|
|
|
+ $form = Form::make_post_form('输入图片url', $formbuider, Url::buildUrl('upload_by_url'));
|
|
|
+ $this->assign(compact('form'));
|
|
|
+ return $this->fetch('public/form-builder');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 移动图片分类显示
|
|
|
*/
|