|
<% //String servletPath=request.getServletPath(); 9 l( M3 C6 v5 W
// int end =servletPath.lastIndexOf('/')+1;
$ P+ u0 x- G3 H$ p( y) o2 P //System.out.println(end);
7 R! p- J6 q' j0 i. U+ \ //String photoPath=servletPath.substring(0,end);
- N5 i2 n3 k+ h String path=request.getRequestURI();
0 h+ x4 p5 Y O5 K4 |7 F8 Q% x# x //System.out.println(path);9 t3 ^. N' w3 D! @ y1 ^6 W$ u2 a
int end =path.lastIndexOf('/')+1;
g5 Y, w' u6 Q8 M1 l2 z8 r String photoPath=path.substring(0,end);" m, r3 y* Z g. l0 \0 b& j
System.out.println(photoPath);, }- V6 _3 U9 U
%>
) M4 |8 N6 V- t, @3 D<script language="javascript">
$ y% C6 K4 ^: K }- y function showPic(obj) {( J, u1 S; y& i' S3 t1 ]/ D' ~
var o = document.getElementById("showimg");
. v7 m4 f1 o! A- c var b = document.getElementById("photoPath");& n; r* X' } F4 l9 r
var i=obj.value.lastIndexOf('s')+2;
0 o" h* F$ e8 N9 d# l* ^ var j=obj.value.length;
7 C. H y! X2 _3 T& w+ f. f //var a = document.image.value;1 w" t: j Z1 I: Q8 e
//var int j=a.length;
) h ]! a0 ~; G //var i=a.lastIndexOf('s')+2;, M. B- n+ f, l' w1 w7 `4 x) G0 d7 y
var filename=obj.value.substring(i,j);+ i' l+ G9 ]1 S, Y% s4 i3 |1 ]
o.src=b.value+"images/"+filename;
# o* F8 R: p4 x o.style.display="";
4 k- N U6 x$ V, w4 e R0 i( o o.border=1;2 S% }4 N/ R4 a
}$ y4 n! x' N5 j
</script>
! F3 H( U8 ~: e3 n! W8 p, X<form>$ t- W, E! e" d0 p0 w) H9 |
<input name="image" type="file" id="image" size="50" >* d# ?3 P7 l2 Q1 z5 h$ s, b
<div align="center"><img name="showimg" id="showimg" src="" style="display:none;" alt="预览图片" /></div>7 Y. n& D1 d( |; w% f; X; D0 g# w; O
</form> |
|