|
<% //String servletPath=request.getServletPath();
' }9 }8 c4 B8 t4 b( ^) l // int end =servletPath.lastIndexOf('/')+1;2 w G2 w z8 q( y# U
//System.out.println(end);
; i) y# Q) n+ Q //String photoPath=servletPath.substring(0,end);1 S; f8 \5 i P# n; }
String path=request.getRequestURI();
0 Y% p% ~- V+ x, B% }, T //System.out.println(path);
% h8 Q9 |) |6 V int end =path.lastIndexOf('/')+1;0 ~# T8 E' z" v ?4 P
String photoPath=path.substring(0,end);
+ c, ~" T; {, {" }: Z1 p System.out.println(photoPath);8 R+ i* R8 e* U
%>
, m' m) H+ R1 J<script language="javascript">
. v0 v% n4 {1 N function showPic(obj) {" b# s% e4 `' j( l% O9 @
var o = document.getElementById("showimg");
: {/ q4 G# X+ H: `: a; m' x var b = document.getElementById("photoPath");
5 ?, o+ s2 R7 L! s7 I% c9 ?5 X var i=obj.value.lastIndexOf('s')+2; a. i8 p4 K7 `. |2 u
var j=obj.value.length;
8 P0 u2 k4 Q l, Q1 Y1 E+ g //var a = document.image.value;
# {( O5 c' q& q- Z //var int j=a.length;" g% k J5 {7 f0 m& C! Y% l
//var i=a.lastIndexOf('s')+2;( [7 l7 {4 b' ]. v( ?* l/ F" G# V
var filename=obj.value.substring(i,j);7 X8 u6 N. h6 {% N r6 _+ {; R% x
o.src=b.value+"images/"+filename;
, ?- p' W7 s+ r2 a9 } h o.style.display="";
4 e4 Z/ w7 a7 {) M o.border=1;
1 ? A; I$ G6 z; v0 d }
6 i$ u! N0 a8 y! h/ Y</script>, H2 J; M7 [7 w! q4 s4 J: k
<form>
7 \$ m* E8 M+ I<input name="image" type="file" id="image" size="50" >- L2 l8 O; h$ h% p+ w4 B( w% u
<div align="center"><img name="showimg" id="showimg" src="" style="display:none;" alt="预览图片" /></div>
' [6 M7 ]) G7 H$ u0 i2 |0 a( l$ t</form> |
|