Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_14980201
ueditor
提交
84ac46a0
U
ueditor
项目概览
qq_14980201
/
ueditor
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
ueditor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
84ac46a0
编写于
11月 04, 2013
作者:
C
campaign
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/dev-1.3.0' into dev-1.3.0
上级
11856e2f
87591329
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
278 addition
and
92 deletion
+278
-92
_parse/charts.js
_parse/charts.js
+1
-1
_src/plugins/charts.js
_src/plugins/charts.js
+20
-0
_src/plugins/defaultfilter.js
_src/plugins/defaultfilter.js
+0
-1
_src/ui/editorui.js
_src/ui/editorui.js
+1
-1
_test/build_run_plugin.xml
_test/build_run_plugin.xml
+1
-1
_test/plugins/basestyle.js
_test/plugins/basestyle.js
+0
-3
_test/plugins/table.action.js
_test/plugins/table.action.js
+24
-19
_test/plugins/undo.js
_test/plugins/undo.js
+3
-1
_test/testDesign/test list for 1.3.0.xmind
_test/testDesign/test list for 1.3.0.xmind
+0
-0
_test/tools/br/config.php
_test/tools/br/config.php
+1
-1
_test/tools/br/js/run.js
_test/tools/br/js/run.js
+37
-1
_test/tools/br/report.php
_test/tools/br/report.php
+47
-6
jsp/Uploader.java
jsp/Uploader.java
+143
-57
jsp/commons-io-2.2-bin.tar.gz
jsp/commons-io-2.2-bin.tar.gz
+0
-0
jsp/ueditor.jar
jsp/ueditor.jar
+0
-0
未找到文件。
_parse/charts.js
浏览文件 @
84ac46a0
...
...
@@ -40,7 +40,7 @@ UE.parse.register('charts',function( utils ){
for
(
var
i
=
0
,
tableNode
;
tableNode
=
tables
[
i
];
i
++
)
{
if
(
tableNode
.
hasAttribute
(
"
data-chart
"
)
)
{
if
(
tableNode
.
getAttribute
(
"
data-chart
"
)
!==
null
)
{
data
.
push
(
formatData
(
tableNode
)
);
...
...
_src/plugins/charts.js
浏览文件 @
84ac46a0
...
...
@@ -58,6 +58,26 @@ UE.plugin.register('charts', function (){
}
}
},
inputRule
:
function
(
root
){
utils
.
each
(
root
.
getNodesByTagName
(
'
table
'
),
function
(
tableNode
){
if
(
tableNode
.
getAttr
(
"
data-chart
"
)
!==
undefined
)
{
tableNode
.
setAttr
(
"
style
"
);
}
})
},
outputRule
:
function
(
root
){
utils
.
each
(
root
.
getNodesByTagName
(
'
table
'
),
function
(
tableNode
){
if
(
tableNode
.
getAttr
(
"
data-chart
"
)
!==
undefined
)
{
tableNode
.
setAttr
(
"
style
"
,
"
display: none;
"
);
}
})
}
}
...
...
_src/plugins/defaultfilter.js
浏览文件 @
84ac46a0
...
...
@@ -154,7 +154,6 @@ UE.plugins['defaultfilter'] = function () {
if
(
val
=
node
.
getAttr
(
'
cdata_tag
'
))
{
node
.
tagName
=
val
;
node
.
setAttr
({
cdata_tag
:
''
,
style
:
''
});
debugger
node
.
innerText
(
utils
.
html
(
node
.
innerText
()),
true
)
}
break
;
...
...
_src/ui/editorui.js
浏览文件 @
84ac46a0
...
...
@@ -261,7 +261,7 @@
}
},
theme
:
editor
.
options
.
theme
,
disabled
:
cmd
==
'
scrawl
'
&&
editor
.
queryCommandState
(
"
scrawl
"
)
==
-
1
disabled
:
(
cmd
==
'
scrawl
'
&&
editor
.
queryCommandState
(
"
scrawl
"
)
==
-
1
)
||
(
cmd
==
'
charts
'
)
});
editorui
.
buttons
[
cmd
]
=
ui
;
editor
.
addListener
(
'
selectionchange
'
,
function
()
{
...
...
_test/build_run_plugin.xml
浏览文件 @
84ac46a0
...
...
@@ -61,7 +61,7 @@
<!--</target>-->
<target
name=
"executeplugin"
depends=
"init,coverage"
>
<get
src=
"http://${serverip}/${git.project}/_test/tools/br/runall.php?ci=true&cov=true&filter=plugins"
<get
src=
"http://${serverip}/${git.project}/_test/tools/br/runall.php?ci=true&cov=true&filter=plugins
,!plugins/table
"
dest=
"/tmp/${git.user}_${git.project}plugin.php"
/>
</target>
<target
name=
"getreportplugin"
depends=
"init,coverage,executeplugin"
>
...
...
_test/plugins/basestyle.js
浏览文件 @
84ac46a0
...
...
@@ -238,7 +238,6 @@ test('ctrl+i', function () {
editor
.
setContent
(
'
<p>没有加粗的文本</p>
'
);
range
.
selectNode
(
body
.
firstChild
).
select
();
var
p
=
body
.
firstChild
;
editor
.
focus
();
setTimeout
(
function
()
{
ua
.
keydown
(
editor
.
body
,
{
'
keyCode
'
:
73
,
'
ctrlKey
'
:
true
});
editor
.
focus
();
...
...
@@ -257,7 +256,6 @@ test('ctrl+u', function () {
editor
.
setContent
(
'
<p>没有加粗的文本</p>
'
);
setTimeout
(
function
()
{
range
.
selectNode
(
body
.
firstChild
).
select
();
editor
.
focus
();
setTimeout
(
function
()
{
var
html
=
'
<span style="text-decoration: underline;">没有加粗的文本</span>
'
;
ua
.
checkHTMLSameStyle
(
html
,
editor
.
document
,
body
.
firstChild
,
'
文本被添加了下划线
'
);
...
...
@@ -276,7 +274,6 @@ test('ctrl+b', function () {
editor
.
setContent
(
'
<p>没有加粗的文本</p>
'
);
range
.
selectNode
(
body
.
firstChild
).
select
();
editor
.
focus
();
setTimeout
(
function
()
{
ua
.
keydown
(
editor
.
body
,
{
'
keyCode
'
:
66
,
'
ctrlKey
'
:
true
});
setTimeout
(
function
()
{
...
...
_test/plugins/table.action.js
浏览文件 @
84ac46a0
...
...
@@ -315,9 +315,9 @@ test('backspace事件:删除caption', function () {
editor
.
execCommand
(
'
insertcaption
'
);
ua
.
keydown
(
editor
.
body
,
{
'
keyCode
'
:
8
});
setTimeout
(
function
()
{
equal
(
te
.
obj
[
0
]
.
body
.
getElementsByTagName
(
'
caption
'
).
length
,
0
,
'
删除caption
'
);
equal
(
te
.
obj
[
0
]
.
selection
.
getRange
().
collapsed
,
true
,
'
检查光标
'
);
equal
(
te
.
obj
[
0
].
selection
.
getRange
().
startContainer
,
te
.
obj
[
0
]
.
body
.
getElementsByTagName
(
'
td
'
)[
0
],
'
检查光标
'
);
equal
(
editor
.
body
.
getElementsByTagName
(
'
caption
'
).
length
,
0
,
'
删除caption
'
);
equal
(
editor
.
selection
.
getRange
().
collapsed
,
true
,
'
检查光标
'
);
equal
(
editor
.
selection
.
getRange
().
startContainer
,
editor
.
body
.
getElementsByTagName
(
'
td
'
)[
0
],
'
检查光标
'
);
start
();
},
20
);
},
50
);
...
...
@@ -330,9 +330,9 @@ test('backspace事件:deleterow', function () {
range
.
setStart
(
editor
.
body
.
firstChild
,
0
).
collapse
(
true
).
select
();
editor
.
execCommand
(
'
inserttable
'
,
{
numCols
:
3
,
numRows
:
3
});
// expect(5); //TODO 1.2.6
editor
.
addListener
(
'
saveScene
'
,
function
()
{
ok
(
true
);
});
//
editor.addListener('saveScene', function () {
//
ok(true);
//
});
stop
();
setTimeout
(
function
()
{
var
trs
=
editor
.
body
.
firstChild
.
getElementsByTagName
(
'
tr
'
);
...
...
@@ -342,9 +342,9 @@ test('backspace事件:deleterow', function () {
range
.
setStart
(
trs
[
0
].
cells
[
0
],
0
).
collapse
(
true
).
select
();
ua
.
keydown
(
editor
.
body
,
{
'
keyCode
'
:
8
});
setTimeout
(
function
()
{
equal
(
te
.
obj
[
0
]
.
body
.
getElementsByTagName
(
'
tr
'
).
length
,
2
,
'
删除整行
'
);
equal
(
te
.
obj
[
0
]
.
selection
.
getRange
().
collapsed
,
true
,
'
检查光标
'
);
equal
(
te
.
obj
[
0
].
selection
.
getRange
().
startContainer
,
te
.
obj
[
0
]
.
body
.
getElementsByTagName
(
'
td
'
)[
0
],
'
检查光标
'
);
equal
(
editor
.
body
.
getElementsByTagName
(
'
tr
'
).
length
,
2
,
'
删除整行
'
);
equal
(
editor
.
selection
.
getRange
().
collapsed
,
true
,
'
检查光标
'
);
equal
(
editor
.
selection
.
getRange
().
startContainer
,
editor
.
body
.
getElementsByTagName
(
'
td
'
)[
0
],
'
检查光标
'
);
start
();
},
100
);
},
50
);
...
...
@@ -356,23 +356,28 @@ test('backspace事件:deletecol', function () {
editor
.
setContent
(
'
<p></p>
'
);
range
.
setStart
(
editor
.
body
.
firstChild
,
0
).
collapse
(
true
).
select
();
editor
.
execCommand
(
'
inserttable
'
,
{
numCols
:
3
,
numRows
:
3
});
stop
();
setTimeout
(
function
(){
var
trs
=
editor
.
body
.
firstChild
.
getElementsByTagName
(
'
tr
'
);
var
ut
=
editor
.
getUETable
(
editor
.
body
.
firstChild
);
var
cellsRange
=
ut
.
getCellsRange
(
trs
[
0
].
cells
[
0
],
trs
[
2
].
cells
[
0
]);
ut
.
setSelected
(
cellsRange
);
range
.
setStart
(
trs
[
0
].
cells
[
0
],
0
).
collapse
(
true
).
select
();
ua
.
keydown
(
editor
.
body
,
{
'
keyCode
'
:
8
});
stop
();
ua
.
keydown
(
trs
[
0
].
cells
[
0
]
,
{
'
keyCode
'
:
8
});
setTimeout
(
function
()
{
equal
(
editor
.
body
.
getElementsByTagName
(
'
tr
'
)[
0
].
getElementsByTagName
(
'
td
'
).
length
,
2
,
'
删除整列
'
);
equal
(
editor
.
selection
.
getRange
().
collapsed
,
true
,
'
检查光标
'
);
equal
(
editor
.
selection
.
getRange
().
collapsed
,
true
,
'
检查光标
'
);
equal
(
editor
.
selection
.
getRange
().
startContainer
,
editor
.
body
.
getElementsByTagName
(
'
td
'
)[
0
],
'
检查光标
'
);
start
();
},
100
);
});
test
(
'
backspace事件:delcells
'
,
function
()
{
//TODO
},
200
);
},
100
);
});
//test('backspace事件:delcells', function () {
// //TODO
//});
test
(
'
表格名称中backspace键
'
,
function
()
{
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
...
...
@@ -390,7 +395,7 @@ test('表格名称中backspace键', function () {
ua
.
keydown
(
editor
.
body
,
{
'
keyCode
'
:
8
});
stop
();
setTimeout
(
function
()
{
editor
=
te
.
obj
[
0
];
//
editor = te.obj[0];
equal
(
editor
.
body
.
getElementsByTagName
(
'
caption
'
).
length
,
0
,
'
删除caption
'
);
equal
(
editor
.
body
.
getElementsByTagName
(
'
table
'
).
length
,
1
,
'
不会增加表格数量
'
);
equal
(
editor
.
body
.
getElementsByTagName
(
'
tr
'
).
length
,
3
,
'
不会增加表格行数量
'
);
...
...
@@ -399,7 +404,7 @@ test('表格名称中backspace键', function () {
equal
(
editor
.
selection
.
getRange
().
startContainer
,
editor
.
body
.
getElementsByTagName
(
'
td
'
)[
0
],
'
检查光标
'
);
start
();
},
5
0
);
},
20
0
);
});
test
(
'
trace 3097 标题行中backspace键
'
,
function
()
{
var
editor
=
te
.
obj
[
0
];
...
...
@@ -997,4 +1002,4 @@ test('点击一列的最上边,选中一列', function () {
start
();
},
500
);
},
50
);
});
\ No newline at end of file
});
_test/plugins/undo.js
浏览文件 @
84ac46a0
module
(
"
plugins.undo
"
);
//test('', function () {
// stop()
//});
/*trace 856*/
test
(
'
trace 856 输入文本后撤销按钮不亮
'
,
function
()
{
var
editor
=
te
.
obj
[
0
];
...
...
@@ -457,7 +460,6 @@ test('ctrl+z/y', function () {
editor
.
setContent
(
'
<p>没有加粗的文本</p>
'
);
range
.
selectNode
(
body
.
firstChild
).
select
();
var
p
=
body
.
firstChild
;
editor
.
focus
();
setTimeout
(
function
()
{
ua
.
keydown
(
editor
.
body
,
{
'
keyCode
'
:
66
,
'
ctrlKey
'
:
true
});
setTimeout
(
function
()
{
...
...
_test/testDesign/test list for 1.3.0.xmind
浏览文件 @
84ac46a0
无法预览此类型文件
_test/tools/br/config.php
浏览文件 @
84ac46a0
...
...
@@ -9,7 +9,7 @@
// , '360ie8' => array('10.81.58.64@8500',"C:\\Program Files\\360\\360se\\360SE.exe")
// , '360ie7' => array( '10.81.58.87@8500' , "C:\\Program Files\\360\\360se\\360SE.exe" )
,
'ie9'
=>
array
(
'10.81.96.46
@8500
'
,
"C:
\\
Program Files
\\
Internet Explorer
\\
iexplore.exe"
)
,
'ie9'
=>
array
(
'10.81.96.46'
,
"C:
\\
Program Files
\\
Internet Explorer
\\
iexplore.exe"
)
// , 'ie6' => array( '10.81.58.86@8500' , "C:\\Program Files\\Internet Explorer\\iexplore.exe" )
,
'chrome'
=>
array
(
'10.81.58.63@8500'
,
"C:
\\
Documents and Settings
\\
geqa1
\\
Local Settings
\\
Application Data
\\
Google
\\
Chrome
\\
Application
\\
chrome.exe"
)
...
...
_test/tools/br/js/run.js
浏览文件 @
84ac46a0
...
...
@@ -143,6 +143,41 @@ function run( kiss, runnext ) {
$
(
'
div#id_runningarea
'
).
empty
().
css
(
'
display
'
,
'
block
'
).
append
(
iframe
);
wb
.
kissstart
=
new
Date
().
getTime
();
};
function
match
(
fileName
,
matcher
)
{
if
(
matcher
==
'
*
'
)
return
true
;
var
len
=
matcher
.
length
;
/**
* 处理多选分支,有一个成功则成功,filter后面参数使用|切割
* @var unknown_type
*/
var
ms
=
matcher
.
split
(
'
,
'
);
if
(
ms
.
length
>
1
)
{
//这里把或的逻辑改成与
for
(
var
matcher1
in
ms
)
{
if
(
!
match
(
fileName
,
ms
[
matcher1
]
)
)
return
false
;
}
return
true
;
}
/**
* 处理反向选择分支
*/
if
(
matcher
.
substr
(
0
,
1
)
==
'
!
'
)
{
var
m
=
matcher
.
substr
(
1
);
if
(
fileName
.
substr
(
0
,
m
.
length
)
==
m
)
return
false
;
return
true
;
}
if
(
len
>
fileName
.
length
)
{
return
false
;
}
return
fileName
.
substr
(
0
,
len
)
==
matcher
;
}
// 需要根据一次批量执行整合所有文件的覆盖率情况
function
covcalc
()
{
function
covmerge
(
cc
,
covinfo
)
{
...
...
@@ -178,7 +213,7 @@ function covcalc() {
if
(
!
cc
.
hasOwnProperty
(
file
)
)
{
continue
;
}
if
(
file
.
indexOf
(
filter
)
!=-
1
)
if
(
match
(
file
,
filter
)
)
files
.
push
(
file
);
}
files
.
sort
();
...
...
@@ -235,6 +270,7 @@ function covcalc() {
if
(
brkisses
[
kiss
]
==
undefined
)
brkisses
[
kiss
]
=
'
0;0;_;0;0
'
;
var
info
=
brkisses
[
kiss
].
split
(
'
;_;
'
);
// 覆盖率的处理在最后环节加入到用例的测试结果中
brkisses
[
kiss
]
=
info
[
0
]
+
'
;
'
+
percentage
+
'
;
'
+
info
[
1
]
+
'
;
'
+
recordCovForBrowser
;
}
}
...
...
_test/tools/br/report.php
浏览文件 @
84ac46a0
...
...
@@ -7,6 +7,42 @@ if (substr_count($_POST['config'], "browser") == 0) {
return
;
}
function
match
(
$fileName
,
$matcher
)
{
if
(
$matcher
==
'*'
)
return
true
;
$len
=
strlen
(
$matcher
);
/**
* 处理多选分支,有一个成功则成功,filter后面参数使用|切割
* @var unknown_type
*/
$ms
=
explode
(
','
,
$matcher
);
if
(
sizeof
(
$ms
)
>
1
)
{
//这里把或的逻辑改成与
foreach
(
$ms
as
$matcher1
)
{
if
(
!
match
(
$fileName
,
$matcher1
)
)
return
false
;
}
return
true
;
}
/**
* 处理反向选择分支
*/
if
(
substr
(
$matcher
,
0
,
1
)
==
'!'
)
{
$m
=
substr
(
$matcher
,
1
);
if
(
substr
(
$fileName
,
0
,
strlen
(
$m
)
)
==
$m
)
return
false
;
return
true
;
}
if
(
$len
>
strlen
(
$fileName
)
)
{
return
false
;
}
return
substr
(
$fileName
,
0
,
$len
)
==
$matcher
;
}
function
report
()
{
/**
...
...
@@ -36,8 +72,10 @@ function report()
continue
;
echo
$key
.
' '
;
$info
=
explode
(
";"
,
$value
);
if
(
$filter
!=
''
&&
(
substr_count
(
$key
,
$filter
)
==
0
||
strpos
(
$key
,
$filter
)
>
0
))
if
(
$filter
!=
''
&&
(
!
match
(
$key
,
$filter
))){
continue
;
}
//errornum + ',' + allnum + ','+ kissPerc || 0 + ',' + wb.kissstart + ','+ wb.kissend;
$casetime
=
(
$info
[
4
]
-
$info
[
3
])
/
1000
;
$time
+=
$casetime
;
...
...
@@ -69,9 +107,11 @@ function report()
$suite
->
setAttribute
(
'failures'
,
$failures
);
$suite
->
setAttribute
(
'tests'
,
$tests
);
if
(
!
is_dir
(
"report_
{
$config
[
'filter'
]
}
"
))
mkdir
(
"report_
{
$config
[
'filter'
]
}
"
);
$dom
->
save
(
"report_
{
$config
[
'filter'
]
}
/
{
$config
[
'browser'
]
}
.xml"
);
// $dirName = "report_{$config['filter']}";
$dirName
=
str_replace
(
'/'
,
'_'
,
"report_
{
$config
[
'filter'
]
}
"
);
if
(
!
is_dir
(
$dirName
))
mkdir
(
$dirName
);
$dom
->
save
(
$dirName
.
"/
{
$config
[
'browser'
]
}
.xml"
);
}
include
'config.php'
;
$config
;
...
...
@@ -87,9 +127,10 @@ report();
$dom
=
new
DOMDocument
(
'1.0'
,
'utf-8'
);
$testsuites
=
$dom
->
appendChild
(
$dom
->
createElement
(
'testsuites'
));
$dirName
=
str_replace
(
'/'
,
'_'
,
"report_
{
$config
[
'filter'
]
}
"
);
foreach
(
Config
::
getBrowserSet
(
$configBrowserSet
)
as
$key
=>
$value
)
{
$file
=
"report_
{
$config
[
'filter'
]
}
/
$key
.xml"
;
$file
=
$dirName
.
"/
$key
.xml"
;
if
(
!
file_exists
(
$file
))
{
echo
"wait for report :
$file
\r\n
<br />"
;
return
;
...
...
jsp/Uploader.java
浏览文件 @
84ac46a0
...
...
@@ -3,22 +3,30 @@ package ueditor;
import
java.io.*
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.fileupload.*
;
import
org.apache.commons.fileupload.servlet.*
;
import
org.apache.commons.fileupload.FileUploadBase.InvalidContentTypeException
;
import
org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException
;
import
org.apache.commons.fileupload.util.*
;
import
org.apache.commons.fileupload.servlet.*
;
import
org.apache.commons.fileupload.FileItemIterator
;
import
org.apache.commons.fileupload.disk.DiskFileItemFactory
;
import
sun.misc.BASE64Decoder
;
import
javax.servlet.http.HttpServletRequest
;
/**
* UEditor文件上传辅助类
*
*/
public
class
Uploader
{
//文件大小常量, 单位kb
private
static
final
int
MAX_SIZE
=
10000
;
// 输出文件地址
private
String
url
=
""
;
// 上传文件名
...
...
@@ -39,13 +47,24 @@ public class Uploader {
private
String
savePath
=
"upload"
;
// 文件允许格式
private
String
[]
allowFiles
=
{
".rar"
,
".doc"
,
".docx"
,
".zip"
,
".pdf"
,
".txt"
,
".swf"
,
".wmv"
,
".gif"
,
".png"
,
".jpg"
,
".jpeg"
,
".bmp"
};
// 文件大小限制,单位
KB
private
int
maxSize
=
1000
0
;
// 文件大小限制,单位
Byte
private
long
maxSize
=
0
;
private
HashMap
<
String
,
String
>
errorInfo
=
new
HashMap
<
String
,
String
>();
private
Map
<
String
,
String
>
params
=
null
;
//上传的文件数据
private
byte
[]
fileBytes
=
null
;
public
static
final
String
ENCODE
=
"utf-8"
;
public
Uploader
(
HttpServletRequest
request
)
{
this
.
request
=
request
;
this
.
params
=
new
HashMap
<
String
,
String
>();
this
.
setMaxSize
(
Uploader
.
MAX_SIZE
);
this
.
parseParams
();
HashMap
<
String
,
String
>
tmp
=
this
.
errorInfo
;
tmp
.
put
(
"SUCCESS"
,
"SUCCESS"
);
//默认成功
tmp
.
put
(
"NOFILE"
,
"未包含文件上传域"
);
...
...
@@ -53,6 +72,7 @@ public class Uploader {
tmp
.
put
(
"SIZE"
,
"文件大小超出限制"
);
tmp
.
put
(
"ENTYPE"
,
"请求类型ENTYPE错误"
);
tmp
.
put
(
"REQUEST"
,
"上传请求异常"
);
tmp
.
put
(
"FILE"
,
"未找到上传文件"
);
tmp
.
put
(
"IO"
,
"IO异常"
);
tmp
.
put
(
"DIR"
,
"目录创建失败"
);
tmp
.
put
(
"UNKNOWN"
,
"未知错误"
);
...
...
@@ -65,58 +85,41 @@ public class Uploader {
this
.
state
=
this
.
errorInfo
.
get
(
"NOFILE"
);
return
;
}
DiskFileItemFactory
dff
=
new
DiskFileItemFactory
();
String
savePath
=
this
.
getFolder
(
this
.
savePath
);
dff
.
setRepository
(
new
File
(
savePath
));
if
(
this
.
fileBytes
==
null
)
{
this
.
state
=
this
.
errorInfo
.
get
(
"FILE"
);
return
;
}
//存储title
this
.
title
=
this
.
getParameter
(
"pictitle"
);
try
{
ServletFileUpload
sfu
=
new
ServletFileUpload
(
dff
);
sfu
.
setSizeMax
(
this
.
maxSize
*
1024
);
sfu
.
setHeaderEncoding
(
"utf-8"
);
FileItemIterator
fii
=
sfu
.
getItemIterator
(
this
.
request
);
while
(
fii
.
hasNext
())
{
FileItemStream
fis
=
fii
.
next
();
if
(!
fis
.
isFormField
())
{
this
.
originalName
=
fis
.
getName
().
substring
(
fis
.
getName
().
lastIndexOf
(
System
.
getProperty
(
"file.separator"
))
+
1
);
if
(!
this
.
checkFileType
(
this
.
originalName
))
{
this
.
state
=
this
.
errorInfo
.
get
(
"TYPE"
);
continue
;
}
this
.
fileName
=
this
.
getName
(
this
.
originalName
);
this
.
type
=
this
.
getFileExt
(
this
.
fileName
);
this
.
url
=
savePath
+
"/"
+
this
.
fileName
;
BufferedInputStream
in
=
new
BufferedInputStream
(
fis
.
openStream
());
FileOutputStream
out
=
new
FileOutputStream
(
new
File
(
this
.
getPhysicalPath
(
this
.
url
)));
BufferedOutputStream
output
=
new
BufferedOutputStream
(
out
);
Streams
.
copy
(
in
,
output
,
true
);
this
.
state
=
this
.
errorInfo
.
get
(
"SUCCESS"
);
//UE中只会处理单张上传,完成后即退出
break
;
}
else
{
String
fname
=
fis
.
getFieldName
();
//只处理title,其余表单请自行处理
if
(!
fname
.
equals
(
"pictitle"
)){
continue
;
}
BufferedInputStream
in
=
new
BufferedInputStream
(
fis
.
openStream
());
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
in
));
StringBuffer
result
=
new
StringBuffer
();
while
(
reader
.
ready
())
{
result
.
append
((
char
)
reader
.
read
());
}
this
.
title
=
new
String
(
result
.
toString
().
getBytes
(),
"utf-8"
);
reader
.
close
();
}
}
}
catch
(
SizeLimitExceededException
e
)
{
this
.
state
=
this
.
errorInfo
.
get
(
"SIZE"
);
}
catch
(
InvalidContentTypeException
e
)
{
this
.
state
=
this
.
errorInfo
.
get
(
"ENTYPE"
);
}
catch
(
FileUploadException
e
)
{
this
.
state
=
this
.
errorInfo
.
get
(
"REQUEST"
);
}
catch
(
Exception
e
)
{
this
.
state
=
this
.
errorInfo
.
get
(
"UNKNOWN"
);
String
savePath
=
this
.
getFolder
(
this
.
savePath
);
if
(!
this
.
checkFileType
(
this
.
originalName
))
{
this
.
state
=
this
.
errorInfo
.
get
(
"TYPE"
);
return
;
}
if
(
this
.
fileBytes
.
length
>
this
.
maxSize
)
{
this
.
state
=
this
.
errorInfo
.
get
(
"SIZE"
);
return
;
}
this
.
fileName
=
this
.
getName
(
this
.
originalName
);
this
.
type
=
this
.
getFileExt
(
this
.
fileName
);
this
.
url
=
savePath
+
"/"
+
this
.
fileName
;
FileOutputStream
fos
=
new
FileOutputStream
(
this
.
getPhysicalPath
(
this
.
url
)
);
fos
.
write
(
this
.
fileBytes
);
fos
.
close
();
this
.
state
=
this
.
errorInfo
.
get
(
"SUCCESS"
);
}
catch
(
Exception
e
)
{
this
.
state
=
this
.
errorInfo
.
get
(
"IO"
);
}
}
/**
...
...
@@ -147,6 +150,12 @@ public class Uploader {
}
}
public
String
getParameter
(
String
name
)
{
return
this
.
params
.
get
(
name
);
}
/**
* 文件类型判断
*
...
...
@@ -172,6 +181,47 @@ public class Uploader {
private
String
getFileExt
(
String
fileName
)
{
return
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
));
}
private
void
parseParams
()
{
DiskFileItemFactory
dff
=
new
DiskFileItemFactory
();
try
{
ServletFileUpload
sfu
=
new
ServletFileUpload
(
dff
);
sfu
.
setSizeMax
(
this
.
maxSize
);
sfu
.
setHeaderEncoding
(
"utf-8"
);
FileItemIterator
fii
=
sfu
.
getItemIterator
(
this
.
request
);
while
(
fii
.
hasNext
())
{
FileItemStream
item
=
fii
.
next
();
//普通参数存储
if
(
item
.
isFormField
()
)
{
this
.
params
.
put
(
item
.
getFieldName
(),
this
.
getParameterValue
(
item
.
openStream
())
);
}
else
{
//只保留一个
if
(
this
.
fileBytes
==
null
)
{
this
.
fileBytes
=
this
.
getFileOutputStream
(
item
.
openStream
()
);
this
.
originalName
=
item
.
getName
();
}
}
}
}
catch
(
SizeLimitExceededException
e
)
{
this
.
state
=
this
.
errorInfo
.
get
(
"SIZE"
);
}
catch
(
InvalidContentTypeException
e
)
{
this
.
state
=
this
.
errorInfo
.
get
(
"ENTYPE"
);
}
catch
(
FileUploadException
e
)
{
this
.
state
=
this
.
errorInfo
.
get
(
"REQUEST"
);
}
catch
(
Exception
e
)
{
this
.
state
=
this
.
errorInfo
.
get
(
"UNKNOWN"
);
}
}
/**
* 依据原始文件名生成新文件名
...
...
@@ -215,6 +265,42 @@ public class Uploader {
.
getRealPath
(
servletPath
);
return
new
File
(
realPath
).
getParent
()
+
"/"
+
path
;
}
/**
* 从输入流中获取字符串数据
* @param in 给定的输入流, 结果字符串将从该流中读取
* @return 从流中读取到的字符串
*/
private
String
getParameterValue
(
InputStream
in
)
{
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
in
)
);
String
result
=
""
;
String
tmpString
=
null
;
try
{
while
(
(
tmpString
=
reader
.
readLine
()
)
!=
null
)
{
result
+=
tmpString
;
}
}
catch
(
Exception
e
)
{
//do nothing
}
return
result
;
}
private
byte
[]
getFileOutputStream
(
InputStream
in
)
{
try
{
return
IOUtils
.
toByteArray
(
in
);
}
catch
(
IOException
e
)
{
return
null
;
}
}
public
void
setSavePath
(
String
savePath
)
{
this
.
savePath
=
savePath
;
...
...
@@ -224,8 +310,8 @@ public class Uploader {
this
.
allowFiles
=
allowFiles
;
}
public
void
setMaxSize
(
int
size
)
{
this
.
maxSize
=
size
;
public
void
setMaxSize
(
long
size
)
{
this
.
maxSize
=
size
*
1024
;
}
public
String
getSize
()
{
...
...
jsp/commons-io-2.2-bin.tar.gz
0 → 100644
浏览文件 @
84ac46a0
文件已添加
jsp/ueditor.jar
浏览文件 @
84ac46a0
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录