切换导航条
此项目
正在载入...
登录
何书鹏
/
anttest
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
PPPSCN
8 years ago
提交
e10619221f8397d79ab2177b25f69b304a76ac58
1 个父辈
716bb2e2
默认本地上传;判断是否已经存在附件,已存在则不上传
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
28 行增加
和
11 行删除
application/admin/command/Install/fastadmin.sql
application/admin/controller/Ajax.php
application/extra/upload.php
public/assets/js/backend/general/attachment.js
public/assets/js/require-upload.js
application/admin/command/Install/fastadmin.sql
查看文件 @
e106192
...
...
@@ -93,7 +93,9 @@ CREATE TABLE `fa_attachment` (
`createtime`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'创建日期'
,
`updatetime`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'更新时间'
,
`uploadtime`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'上传时间'
,
PRIMARY
KEY
(
`id`
)
`sha1`
varchar
(
40
)
NOT
NULL
DEFAULT
''
COMMENT
'文件 sha1编码'
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`sha1`
(
`sha1`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'附件表'
;
-- ----------------------------
...
...
application/admin/controller/Ajax.php
查看文件 @
e106192
...
...
@@ -183,6 +183,16 @@ class Ajax extends Backend
{
$this->code
= -1;
$file
=
$this->request
->file('file');
//判断是否已经存在附件
$sha1
=
$file->hash
();
$uploaded
= model("
attachment
")->where('sha1',
$sha1
)->find();
if(
$uploaded
){
$this->code
= 200;
$this->data
=
$uploaded['url']
;
return;
}
$upload
= Config::get('upload');
preg_match('/(\d+)(\w+)/',
$upload['maxsize']
,
$matches
);
...
...
@@ -230,7 +240,8 @@ class Ajax extends Backend
'imageframes' => 0,
'mimetype' =>
$fileInfo['type']
,
'url' =>
$uploadDir
.
$splInfo->getSaveName
(),
'uploadtime' => time()
'uploadtime' => time(),
'sha1' =>
$sha1
,
);
model("
attachment
")->create(array_filter(
$params
));
$this->code
= 200;
...
...
application/extra/upload.php
查看文件 @
e106192
...
...
@@ -5,19 +5,19 @@ return [
/**
* 上传地址,如果不使用又拍云,则可以使用/ajax/upload
*/
'uploadurl'
=>
'
http://v0.api.upyun.com/yourbucketname
'
,
'uploadurl'
=>
'
/admin/ajax/upload
'
,
/**
* 又拍云或本机的CDN地址
*/
'cdnurl'
=>
'
http://yourbucketname.b0.upaiyun.com
'
,
'cdnurl'
=>
''
,
/**
* 上传成功后的通知地址
*/
'notifyurl'
=>
'
http://www.yoursite.com/upyun/notify
'
,
'notifyurl'
=>
''
,
/**
* 又拍云Bucket
*/
'bucket'
=>
'
yourbucketname
'
,
'bucket'
=>
''
,
/**
* 生成的policy有效时间
*/
...
...
@@ -29,7 +29,7 @@ return [
/**
* 文件保存格式
*/
'savekey'
=>
'/uploads/
media/
{year}{mon}{day}/{filemd5}{.suffix}'
,
'savekey'
=>
'/uploads/{year}{mon}{day}/{filemd5}{.suffix}'
,
/**
* 最大可上传大小
*/
...
...
public/assets/js/backend/general/attachment.js
查看文件 @
e106192
...
...
@@ -54,9 +54,13 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table', 'config'], function (
},
formatter
:
{
thumb
:
function
(
value
,
row
,
index
)
{
console
.
log
(
row
);
//
console.log(row);
if
(
row
.
mimetype
.
indexOf
(
"image"
)
>
-
1
)
{
return
'<a href="'
+
Config
.
upload
.
cdnurl
+
value
+
'" target="_blank"><img src="'
+
Config
.
upload
.
cdnurl
+
value
+
'!/fwfh/50x50" alt=""></a>'
;
if
(
Config
.
upload
.
bucket
.
replace
(
/^
\s
+|
\s
+$/gm
,
''
).
length
===
0
){
return
'<a href="'
+
Config
.
upload
.
cdnurl
+
value
+
'" target="_blank"><img src="'
+
Config
.
upload
.
cdnurl
+
value
+
'" alt="" style="max-height:90px;max-width:120px"></a>'
;
}
else
{
return
'<a href="'
+
Config
.
upload
.
cdnurl
+
value
+
'" target="_blank"><img src="'
+
Config
.
upload
.
cdnurl
+
value
+
'!/fwfh/50x50" alt=""></a>'
;
}
}
else
{
return
'无'
;
}
...
...
public/assets/js/require-upload.js
查看文件 @
e106192
...
...
@@ -69,11 +69,11 @@ define(['jquery', 'bootstrap', 'backend', 'config', 'plupload'], function ($, un
try
{
var
ret
=
JSON
.
parse
(
info
.
response
);
if
(
ret
.
hasOwnProperty
(
'code'
))
{
ret
.
data
=
ret
.
code
==
200
?
ret
:
ret
.
data
;
ret
.
data
=
ret
.
code
==
200
?
ret
.
data
:
ret
.
data
;
ret
.
code
=
ret
.
code
==
200
?
1
:
ret
.
code
;
var
data
=
ret
.
hasOwnProperty
(
"data"
)
&&
ret
.
data
!=
""
?
ret
.
data
:
null
;
var
msg
=
ret
.
hasOwnProperty
(
"msg"
)
&&
ret
.
msg
!=
""
?
ret
.
msg
:
""
;
$
(
"input[data-plupload-id='"
+
id
+
"-text']"
).
val
(
data
.
url
);
$
(
"input[data-plupload-id='"
+
id
+
"-text']"
).
val
(
data
);
var
afterUpload
=
$
(
"#"
+
id
).
data
(
"after-upload"
);
if
(
afterUpload
&&
typeof
Upload
.
api
.
custom
[
afterUpload
]
==
'function'
)
{
Upload
.
api
.
custom
[
afterUpload
].
call
(
info
,
id
,
data
);
...
...
请
注册
或
登录
后发表评论