JSP上传图片源码

<%@page import="org.apache.jasper.tagplugins.jstl.core.Redirect"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>这是一个上传页面</title>
<base href="<%=basePath%>">
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
</head>
<body>
<center>
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="60"
style="color: #000; font-size: 19px; font-weight: bolder; padding-left: 50px;">上传吧</td>
</tr>
<tr>
<td height="30"> </td>
</tr>
<tr>
<td height="500" align="center" valign="top"><table width="900"
border="0" cellspacing="0" cellpadding="0">
<tr>
        <td></td>
<td width="709" align="center" valign="top">
<form action="admin/uploadI" method="post" enctype="multipart/form-data">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="38%" height="60" align="right"> 请选择级别</td>
<td width="62%">  <select name="select2">
<script>
                                                                         for(var i=1;i<=24;i++){
                                                                       document.write("<option value='"+i+"'>"+i+"</option>");
                                                                           }
                                                                       </script>
</select></td>
</tr>
<tr><td width="38%" height="60" align="right"> 请选择性别</td>
<td width="62%">  <select name="select3">
<option value="1" >男</option>
<option value="0" selected="selected" >女</option>
</select></td></tr>
<tr>
<td height="60" align="right"><span>*</span>上传图片:</td>
<td><input type="file" name="myfile" id="myfile"
onchange="showPreviewImg(this)"></td>
</tr>
<tr>
<td> </td>
<td align="left" ><img id="previewImg"
src="image/yulan.png" width="100" height="120" /></td>

</tr>

<tr>
<td colspan="2" align="center"><div id="large"></div></td>
</tr>
                   <tr><span onclick="return searchAll1()">上一页</span>  第<input onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" size="1" id="page" value="${page}" name="page"/>页 <span onclick="return searchAll3()" >GO</span>  <span onclick="return searchAll2()">下一页</span>  共${pageCount}页</tr> 
<tr height="80">
<td> </td>
<td align="left"><input type="submit" name="button" id="button"
value="上传"><%if(request.getAttribute("result")!=null){%>
                                            <span style="color:red;">
                                            <%=request.getAttribute("result")%></span>
                                            <%}%></td>
</tr>
</table>
</form>
</td>
</tr>
</table></td>
</tr>
<tr>
<td height="35"> </td>
</tr>
</table>


</center>
</body>
<script language="JavaScript"> 
$('#myfile').change(function() {
var file = this.files[0];
var reader = new FileReader();
reader.onload = function() {
var url = reader.result;
setImageURL(url);
};
reader.readAsDataURL(file);
var la = $("#large");
//la.hide();
$("#previewImg").mousemove(function(e) {
la.css({
top : e.pageY,
left : e.pageX
}).html('<img src="'+this.src+'"/>').show();
}).mouseout(function() {
la.hide();
});
});
var image = $("#previewImg")[0];
function setImageURL(url) {
image.src = url;
}
javascript:window.history.forward(1); 


</script>
<script language="JavaScript"> 
var pageCount=${pageCount};
function searchAll1(){
var page1=document.getElementById("page").value;
if(page1>1){
page1--;
window.location.href="admin/searchAll?page="+page1;
}
}
function searchAll2(){
var page1=document.getElementById("page").value;
if(page1<pageCount){
page1++;
window.location.href="admin/searchAll?page="+page1;
}
}
//判空
function isNull(str){
if ( str == "" ) return true;
var regu = "^[ ]+$";
var re = new RegExp(regu);
return re.test(str);
}

function searchAll3(){
var page1=document.getElementById("page").value;
if(page1<=pageCount){
window.location.href="admin/searchAll?page="+page1;
}
else{
alert("输入页码有误!");
window.location.href="admin/searchAll?page=1";
}
}




javascript:window.history.forward(1); 


</script>
</html>

最近在整理一些资源工具,放在网站分享 http://tools.maqway.com
欢迎关注公众号:麻雀唯伊 , 不定时更新资源文章,生活优惠,或许有你想看的

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值