|
<% //String servletPath=request.getServletPath(); : F7 g9 s; Q m9 o; |
// int end =servletPath.lastIndexOf('/')+1;
& \, q+ s/ `0 B1 M+ y. p9 n3 z //System.out.println(end);
& d0 G3 G# w! C* P7 x6 r //String photoPath=servletPath.substring(0,end);
c, }3 p0 B8 @( S, g4 N6 I' J* H& { String path=request.getRequestURI();
* L5 L7 J$ |) v0 b //System.out.println(path);& v& T8 n6 k& d+ ]7 v$ Z
int end =path.lastIndexOf('/')+1;
# }2 o9 L; t' ~! k! c8 r String photoPath=path.substring(0,end);
% t% J/ I$ ?& p) y9 n6 D0 i System.out.println(photoPath);# t+ K" d8 o' o3 w3 U! L7 t
%>
% h7 j6 k+ o p$ V7 Y<script language="javascript">. r6 u# B7 `( g" [# o- @
function showPic(obj) {
' Y, y/ S& t( `4 k! Q" d7 J! X var o = document.getElementById("showimg");
7 t7 X P. V* u1 J/ L9 s H var b = document.getElementById("photoPath");
; V. o+ i! i4 q var i=obj.value.lastIndexOf('s')+2;
3 Z5 G% z- p# L6 d$ B. m var j=obj.value.length;7 f! Q2 O2 e7 d, U3 j# y1 P! v) e
//var a = document.image.value;
4 S1 s" O2 `: V; n //var int j=a.length;, O) E4 d' x$ M5 _ P
//var i=a.lastIndexOf('s')+2;8 \% S: m# c: |2 \4 W/ L( o, J- {6 y
var filename=obj.value.substring(i,j);2 Y2 V9 x( r t8 @0 k/ \ }6 f
o.src=b.value+"images/"+filename;
3 q# n7 A& `1 u: r+ n o.style.display="";* B. c* U" f P5 u! o
o.border=1;
4 w$ ~8 Z" C+ h( x }
! c0 X5 C$ X5 G5 C</script>
, I. p5 h# {! U/ c3 B* b6 h9 S<form>( N9 j. i; y+ t! j3 {' A
<input name="image" type="file" id="image" size="50" >
$ Z2 ]3 \# o3 ]/ w<div align="center"><img name="showimg" id="showimg" src="" style="display:none;" alt="预览图片" /></div>
* a+ k5 F; Q9 ] O; ^</form> |
|