|
<% //String servletPath=request.getServletPath();
4 S/ u! P+ Q+ i) ^9 F2 m5 ~ // int end =servletPath.lastIndexOf('/')+1;
# g5 P' r- G6 B7 X9 T //System.out.println(end);% z( p% k3 E8 l+ X. a
//String photoPath=servletPath.substring(0,end);3 F: j( N: K2 |% T% p7 b6 v F
String path=request.getRequestURI();
& S+ x) C# W9 u/ z //System.out.println(path);$ n0 p: p0 C8 B7 Q4 S
int end =path.lastIndexOf('/')+1;0 g: C/ t' R) P4 H! a: P! Q) ~
String photoPath=path.substring(0,end);6 E) l4 ~# ~& R4 k) X
System.out.println(photoPath);
/ [# H: V) W2 S) j7 C %>4 v' O+ i4 L3 C" A
<script language="javascript">9 W3 K' c. F2 y5 U9 I f9 \2 ^, U
function showPic(obj) {5 l f( A3 B0 Y* M5 m
var o = document.getElementById("showimg");
6 w* G, @; H2 G) s6 | var b = document.getElementById("photoPath");
& `0 i; |7 W W& M% D# L* b, ~' F var i=obj.value.lastIndexOf('s')+2;
. K1 f8 |% u7 {, j/ c# E/ q var j=obj.value.length;. |2 \" P1 H6 q' ^) L9 v0 n1 }
//var a = document.image.value;8 `$ F! e( d; t: d- y& |$ h
//var int j=a.length;
/ w4 g/ k/ U' p" L0 q2 R3 q //var i=a.lastIndexOf('s')+2;
# F5 R+ r% N2 G/ A$ V, @ var filename=obj.value.substring(i,j);2 J! L' P h9 ~ a7 Z
o.src=b.value+"images/"+filename;
( S' l$ C* @2 `, d- P6 K* D o.style.display="";
. k4 x, {6 I& {2 o3 G4 e/ t2 ^ o.border=1;
: P7 Q. l" |% J( J: t& o# L }
# l, U: F/ Z4 t, q/ I</script>2 V# x0 u' {; C3 B& \! G1 H
<form>2 a- {* B! l3 s
<input name="image" type="file" id="image" size="50" >6 r) \* a7 h: x8 [1 r
<div align="center"><img name="showimg" id="showimg" src="" style="display:none;" alt="预览图片" /></div>
! t" ^2 s7 ~9 ?, y</form> |
|