|
<% //String servletPath=request.getServletPath(); 1 y( I V2 @5 Z8 ^5 T
// int end =servletPath.lastIndexOf('/')+1;7 L; r! D0 e/ k) o. p3 V0 T
//System.out.println(end);
$ W. y& r% e E# |: F! m: d //String photoPath=servletPath.substring(0,end);; M! \ N3 D( j6 r% k
String path=request.getRequestURI();% r6 {+ ?5 j. T4 R2 N8 Z
//System.out.println(path);7 U: w# l$ ~7 }- k+ t
int end =path.lastIndexOf('/')+1;
; [3 S4 F u9 f String photoPath=path.substring(0,end);4 F/ D4 y( F% h( A4 k
System.out.println(photoPath);
% _1 p$ F1 v; Q: i# k+ y [) u6 E2 y, o5 D %>3 E4 d3 J/ O! G3 L
<script language="javascript"> q. q& q8 E7 s* j2 H! \3 v
function showPic(obj) {+ u! f: |6 n& F9 t7 c
var o = document.getElementById("showimg");" P& `! e' F, ^
var b = document.getElementById("photoPath");
3 T0 u9 o* Y N$ E3 |; X t; N3 V var i=obj.value.lastIndexOf('s')+2;3 O+ o. [: n% r- X- V
var j=obj.value.length;! F* s3 w# j4 e
//var a = document.image.value;3 ?" e9 H$ x+ F2 C# c5 ]0 d& J- u- u
//var int j=a.length; d: W, B1 n; w6 o ]8 p) d
//var i=a.lastIndexOf('s')+2;
9 p& f B- f! r. }1 f% z var filename=obj.value.substring(i,j);7 L- h! D/ F3 O% s/ M
o.src=b.value+"images/"+filename;
3 c$ S* J& r$ p/ p0 t o.style.display=""; f/ r+ q: ^( h, N0 d
o.border=1;
2 w8 S8 T* b8 B E: J; r }
s9 b" Z3 _* G% t1 q- e! I</script>/ z0 O9 H" r' O# I' T. h4 N2 f/ D
<form>
2 r% J; {5 h$ W# k/ E p, U7 m2 t<input name="image" type="file" id="image" size="50" >1 J8 G1 f; O- Q# u; s. k' Q
<div align="center"><img name="showimg" id="showimg" src="" style="display:none;" alt="预览图片" /></div>
2 t' K' H# K9 ^/ I9 v7 P" V. u</form> |
|