|
<% //String servletPath=request.getServletPath(); 6 \, j! s+ {* S% A# F7 m; `- {/ A
// int end =servletPath.lastIndexOf('/')+1;
! l3 C( P3 z+ J: a0 K1 u, i- Y( X, S //System.out.println(end);
7 }8 u/ \% H) e# J( V //String photoPath=servletPath.substring(0,end);
) c: d* P9 l9 A" C$ d String path=request.getRequestURI();# T% M, W# o- }
//System.out.println(path);
( V$ c% b7 u6 q7 Y1 z3 }6 L; ] int end =path.lastIndexOf('/')+1;
c, a4 R* m# e: }0 o' @0 j String photoPath=path.substring(0,end);- n% U5 b# R8 W) {: t
System.out.println(photoPath);
/ R; T* w8 ~# F( h %>
5 P6 G8 Z; c j' j/ A+ J<script language="javascript">" T3 l. ]8 \! O. M
function showPic(obj) {
7 Y$ y: T: Q& K7 x5 r M var o = document.getElementById("showimg");
$ P+ k8 Z' r! { var b = document.getElementById("photoPath");) d; F3 Y( D) V' V. ~
var i=obj.value.lastIndexOf('s')+2;
* w" N Y: M0 d0 b Y% E0 g. Z0 H var j=obj.value.length;
; X" {4 x w4 C; }& W2 ? //var a = document.image.value;4 r, {' X, L0 f$ d9 D* w
//var int j=a.length;
7 ]! `8 G# G2 z$ O //var i=a.lastIndexOf('s')+2;
, h5 f! b5 s Q var filename=obj.value.substring(i,j);
9 J* X8 X: z) z c+ f6 D1 `. ] o.src=b.value+"images/"+filename;
$ d' D. K- S9 K! x9 r9 g o.style.display="";3 d8 L X1 J- {" m l9 T( q! x: [
o.border=1;
; V0 F8 @9 b' `: t" Z$ X9 i; {0 j }
4 q$ h/ m0 J6 V</script>
2 [( I4 ^& n" n, b8 y<form>
) y. \ {# L+ [5 H; l1 ?<input name="image" type="file" id="image" size="50" >& n- l1 \- X# h% U( k# o$ H
<div align="center"><img name="showimg" id="showimg" src="" style="display:none;" alt="预览图片" /></div>/ P# N" J7 i$ z+ X5 S% n7 b
</form> |
|