项目中有上传头像功能,需要对上传的图片进行截取,原来使用的是Flash插件上传,但是不可控制。最后看到这个Jcrop组件还不错,就尝试用了一下感觉还不错的!这里分享给大家
先说明下我搭建的环境是:springMVC+spring+mybatis。下面直接上代码:
一、jsp页面:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<
form
name
=
"form"
action="<%=request.getContextPath()%>/UploadDemo/uploadHeadImage" class="form-horizontal"
method="post" enctype="multipart/form-data">
<
div
class
=
"modal-body text-center"
>
<
div
class
=
"zxx_main_con"
>
<
div
class
=
"zxx_test_list"
>
<
input
class
=
"photo-file"
type
=
"file"
name
=
"imgFile"
id
=
"fcupload"
onchange
=
"readURL(this);"
/>
<
img
alt
=
""
src
=
""
id
=
"cutimg"
/>
<
input
type
=
"hidden"
id
=
"x"
name
=
"x"
/>
<
input
type
=
"hidden"
id
=
"y"
name
=
"y"
/>
<
input
type
=
"hidden"
id
=
"w"
name
=
"w"
/>
<
input
type
=
"hidden"
id
=
"h"
name
=
"h"
/>
</
div
>
</
div
>
</
|