|
<% //String servletPath=request.getServletPath();
+ |- F1 L1 e. I% [ X: P6 s# ? // int end =servletPath.lastIndexOf('/')+1;: f* T4 {& R: s2 d
//System.out.println(end);
$ X( h ~% Y# v% y8 S, C //String photoPath=servletPath.substring(0,end);9 R0 P; c/ h' d' j* ]! H
String path=request.getRequestURI();
. a2 A/ y2 u7 O/ {) ~! @ //System.out.println(path);
. U/ p# u" P6 w4 ^ int end =path.lastIndexOf('/')+1;: o1 \7 q2 y* Z8 }- w: B
String photoPath=path.substring(0,end);7 l, f; r- C4 o9 z7 q
System.out.println(photoPath);
5 e+ r) f0 {8 T& ~ %>
4 _( l- J1 U, a$ y<script language="javascript">
6 D, J/ a" M; @. P function showPic(obj) {0 s" ^2 k% D1 p: _* C/ k
var o = document.getElementById("showimg");
! ?4 p( o8 R; Z2 W/ e var b = document.getElementById("photoPath");: f" D+ h& z% O8 S& `( H( y; f1 p
var i=obj.value.lastIndexOf('s')+2;% H; L3 Y( z. I) G3 x& U3 `6 e& W
var j=obj.value.length;5 [9 r% ~7 F. h, b, q6 X
//var a = document.image.value;# U5 G* | g; ~! J# _8 I
//var int j=a.length;
e. ]$ {1 |5 U$ l //var i=a.lastIndexOf('s')+2;9 g% W w% U" i: d6 F+ T
var filename=obj.value.substring(i,j);
5 _- A& P# B: c o.src=b.value+"images/"+filename;9 }0 Z) e; ~# B! L8 ~) j3 y1 U
o.style.display="";; i T/ p! ?1 u3 s
o.border=1;
- ?( n1 ]/ D8 l, O L7 l4 t! l4 W }
: y" @0 e. g9 U! r5 u( L2 `</script>
+ K1 W1 I8 e2 N$ M1 E( |( r: l2 Q2 _6 {<form>
+ M% ]! r5 [8 J1 {) A3 m<input name="image" type="file" id="image" size="50" >
) u9 ~ j0 A1 C0 u/ h<div align="center"><img name="showimg" id="showimg" src="" style="display:none;" alt="预览图片" /></div>
. b9 {/ U+ ]9 `. e</form> |
|