|
<% //String servletPath=request.getServletPath();
7 m3 n2 R* I5 s9 `4 Q$ F // int end =servletPath.lastIndexOf('/')+1;
w# U/ |! l, U2 p2 I6 ` //System.out.println(end);
6 s# ]% U0 R4 v: `* ^ //String photoPath=servletPath.substring(0,end);/ h- a& \' V' ^" x9 ~8 W
String path=request.getRequestURI();
8 i( N! }2 K( J. a9 | //System.out.println(path);
t0 `( x- ]3 n: Z' @ int end =path.lastIndexOf('/')+1;
; @9 C$ h/ Z8 K# s, Z3 F; R String photoPath=path.substring(0,end);
9 h, c* @! k. H/ J3 E+ K System.out.println(photoPath);6 k0 Q/ Y, A/ Q: m8 M, u% e9 I( P
%>
: s: K& A: ]& R<script language="javascript">
8 l* v$ E; G# J9 u function showPic(obj) {
9 y' v3 l9 _6 Q/ \. F0 Z var o = document.getElementById("showimg");
: F Q. a* b% l, L# P# ]" ` var b = document.getElementById("photoPath");
, `4 m# ?$ q& p7 l6 R1 t1 I% z$ \ var i=obj.value.lastIndexOf('s')+2;
+ q% K) g6 b2 X" e S7 D var j=obj.value.length;
* g) A+ w( x& K, ^# `9 e, P) u //var a = document.image.value; P2 M5 F. Y$ P4 v% N% |! }/ E
//var int j=a.length;) G f" O2 ]& d6 a4 G/ R T
//var i=a.lastIndexOf('s')+2;) s4 e8 ]8 p* o3 i5 [" f2 F& f: |
var filename=obj.value.substring(i,j);
a: o- v4 v6 B o.src=b.value+"images/"+filename;
9 ]( U; W# U B, S; u) O% Z3 ? o.style.display="";
3 g) S% G6 d$ `5 A1 p8 w# t o.border=1;8 X, s- b9 u1 Y2 F' ] M5 w( }
}4 I+ ^& z1 w7 H# Z6 x- K) a
</script>9 T0 n5 c) G+ Y9 h( O
<form>
6 G. D( v; O/ m0 m<input name="image" type="file" id="image" size="50" >, |* s& i* M# v' k% a, U" b/ E/ S! B
<div align="center"><img name="showimg" id="showimg" src="" style="display:none;" alt="预览图片" /></div>) B8 Z$ S0 w: }$ ]4 O0 W( U
</form> |
|