连接jsp图片上传/放大缩小/裁减的源代码

怎么把图片缩小  时间:2021-02-21  阅读:()

3000分求JSP图片上传放大缩小裁减的源代码

1 #大中小发表于2009-08-27 10:33:00

3000分求JSP图片上传放大缩小裁减的源代码。能裁减固定大小比如      的就行。有预览能显示图片长宽和大小file size)最好。

本人结帖率是99.87%, 可用分   +

dsf 如果没有JSP源代码 PHP源代码也可以。

String picPath;//图片路径 如:F:picturea.gifpublic String pictype[] ;//设置图片的后缀名FileInputStream in;int piclength;//设置图片的最大kb

}

public void setpiclength)//设置图片的最大长

{this.piclength=piclength;

}public int getpiclength()

{return piclength;

}public boolean testlength()//判断图片的长度是否大于设定的最大长度

{try{in=new FileInputStream(picPath) ;if(in.available()/1024>piclength)return false;

}catch(IOException e)

{

System.out.println(e.getMessage() ) ;

}return true;

}public void setpictype(String[] pictype)//设置图片的扩展名

{this.pictype=pictype;

}public boolean testpictype()//判断图片的扩展名是否是规定的

{if(pictype!=null)

{for(int i=0; i <pictype. length; i )

{if(picPath.endsWith(pictype) )return true;

}return false;

}return false;

}

}

以下是在jsp页面中调用uploadpic

首先要引入此bean所在的包

<%@page import="myBean.uploadpic" %>

<jsp:useBean id="pic" scope="page" class="myBean.uploadpic" />下一条语句是得到上一层页面也就是用户提交的图片路径

Stringpicp=codetostring.codeToString(request.getParameter("picPath")) ;pic. setpicPath(picp) ;pic. setpiclength(100) ;//以kb为单位if(pic. testlength() )out.print("length ok <br>") ;elseout.print("length ok") ;

String p1,p2;p1=". jpg";p2=".gif";

String[] type={p1,p2} ;pic. setpictype(type) ;if(pic. testpictype() )out.print("typeok") ;elseout.print("type error") ;made by zonecens www.okjava.net.cn

不知道2楼的怎么样我来学习一个

帮顶

好像百度一招很多

百度一下找到相关网页约11,400,000篇用时0.036秒3000连个星星都升不了

这个是JAVA代码package ftp;import sun.net.ftp.*;import sun.net.*;import java.awt.*;import java.awt.event.*;import java.applet.*;

import java. io.*;class FTPextends Applet {

FtpClient aftp;

DataOutputStream outputs;

TelnetInputStream ins;

TelnetOutputStream outs;

TextArea lsArea;

Label LblPrompt;

Button BtnConn;

Button BtnClose;

TextField TxtUID;

TextField TxtPWD;

TextField TxtHost;int ch;public String a = "没有连接主机";

String hostname = "";public void init() {setBackground(Color.white) ;setLayout(new GridBagLayout() ) ;

GridBagConstraints GBC = new GridBagConstraints() ;

LblPrompt = new Label ("没有连接主机") ;LblPrompt. setAlignment(Label.LEFT) ;BtnConn = new Button("连接") ;

BtnClose = new Button("断开") ;

BtnClose.enable(false) ;

TxtUID = new TextField("", 15) ;TxtPWD = new TextField("", 15) ;TxtPWD. setEchoCharacter('*' ) ;

TxtHost = new TextField("", 20) ;Label LblUID = new Label ("User ID:") ;Label LblPWD = new Label ("PWD:") ;Label LblHost = new Label ("Host:") ;

lsArea = new TextArea(30, 80) ;lsArea. setEditable(false) ;

GBC.gridwidth = GridBagConstraints.REMAINDER;GBC.f ill = GridBagConstraints.HORIZONTAL;( (GridBagLayout) getLayout() ) . setConstraints(LblPrompt, GBC) ;add(LblPrompt) ;

GBC.gridwidth = 1 ;

( (GridBagLayout) getLayout() ) . setConstraints(LblHost, GBC) ;add(LblHost) ;

GBC.gridwidth = GridBagConstraints.REMAINDER;( (GridBagLayout) getLayout() ) . setConstraints(TxtHost, GBC) ;add(TxtHost) ;

GBC.gridwidth = 1 ;

( (GridBagLayout) getLayout() ) . setConstraints(LblUID, GBC) ;add(LblUID) ;

GBC.gridwidth = 1 ;

( (GridBagLayout) getLayout() ) . setConstraints(TxtUID, GBC) ;add(TxtUID) ;

GBC.gridwidth = 1 ;

( (GridBagLayout) getLayout() ) . setConstraints(LblPWD, GBC) ;add(LblPWD) ;

GBC.gridwidth = 1 ;

( (GridBagLayout) getLayout() ) . setConstraints(TxtPWD, GBC) ;add(TxtPWD) ;

GBC.gridwidth = 1 ;

GBC.weightx = 2;

( (GridBagLayout) getLayout() ) . setConstraints(BtnConn, GBC) ;add(BtnConn) ;

GBC.gridwidth = GridBagConstraints.REMAINDER;( (GridBagLayout) getLayout() ) . setConstraints(BtnClose, GBC) ;add(BtnClose) ;

GBC.gridwidth = GridBagConstraints.REMAINDER;GBC.f ill = GridBagConstraints.HORIZONTAL;( (GridBagLayout) getLayout() ) . setConstraints(lsArea, GBC) ;add(lsArea) ;

}public boolean connect(String hostname, String uid,String pwd) {this.hostname = hostname;

LblPrompt. setText("正在连接请等待. . . . . ") ;try {aftp = new FtpClient(hostname) ;aftp. login(uid, pwd) ;aftp.binary() ;showFileContents() ;

}catch (FtpLoginException e) {a = "无权限与主机:" + hostname + "连接!";

LblPrompt. setText(a) ;return false;

}catch (IOException e) {a = "连接主机:" + hostname + "失败!";

LblPrompt. setText(a) ;return false;

}catch (SecurityException e) {a = "无权限与主机:" + hostname + "连接!";

LblPrompt. setText(a) ;return false;

}

LblPrompt. setText("连接主机:" + hostname + "成

功!") ;return true;

}

public void stop() {try {aftp.closeServer() ;

}catch (IOException e) {

}

}public void paint(Graphics g) {

}public boolean action(Event evt, Object obj) {if (evt. target == BtnConn) {

LblPrompt. setText("正在连接请等待. . . . . ") ;if (connect(TxtHost.getText() , TxtUID.getText() , TxtPWD.getText() ) ) {

BtnConn. setEnabled(false) ;

BtnClose. setEnabled(true) ;

}return true;

}if (evt. target == BtnClose) {

stop() ;

BtnConn.enable(true) ;

BtnClose.enable(false) ;

LblPrompt. setText("与主机" + hostname + "连

接已断开!") ;return true;

}return super.action(evt, obj) ;

}public boolean sendFile(String filepathname) {boolean result = true;if (aftp != null) {

LblPrompt. setText("正在粘贴文件,请耐心等

待. . . . ") ;

String contentperline;try {a = "粘贴成功!";

String fg = new String("\") ;int index = filepathname. lastIndexOf(fg) ;String filename = filepathname. substring(index + 1) ;

File localFile;localFile = new File(filepathname) ;RandomAccessFile sendFile = new RandomAccessFile(filepathname, "r") ;

//sendFile. seek(0) ;outs = aftp.put(filename) ;outputs = new DataOutputStream(outs) ;while (sendFile.getFilePointer() < sendFile. length() ) {ch = sendFile.read() ;outputs.write(ch) ;

}outs.close() ;sendFile.close() ;

}catch (IOException e) {a = "粘贴失败!";result = false;

}

LblPrompt. setText(a) ;showFileContents() ;

}else {result = false;

}return result;

}public void showFileContents() {StringBuffer buf = new StringBuffer() ;lsArea. setText("") ;try {ins = aftp. list() ;while ( (ch = ins.read() ) >= 0) {buf.append( (char) ch) ;

}lsArea.appendText(buf. toString() ) ;ins.close() ;

}catch (IOException e) {

}

}public static void main(String args[] ) {Frame f = new Frame("FTP Client") ;f.addWindowListener(new WindowAdapter() {

湖北22元/月(昔日数据)云服务器,国内湖北十堰云服务器,首月6折

昔日数据怎么样?昔日数据新上了湖北十堰云服务器,湖北十堰市IDC数据中心 母鸡采用e5 2651v2 SSD MLC企业硬盘 rdid5阵列为数据护航 100G高防 超出防御峰值空路由2小时 不限制流量。目前,国内湖北十堰云服务器,首月6折火热销售限量30台价格低至22元/月。(注意:之前有个xrhost.cn也叫昔日数据,已经打不开了,一看网站LOGO和名称为同一家,有一定风险,所以尽量不要选择...

RAKsmart:美国圣何塞服务器限量秒杀$30/月起;美国/韩国/日本站群服务器每月189美元起

RAKsmart怎么样?RAKsmart是一家由华人运营的国外主机商,提供的产品包括独立服务器租用和VPS等,可选数据中心包括美国加州圣何塞、洛杉矶、中国香港、韩国、日本、荷兰等国家和地区数据中心(部分自营),支持使用PayPal、支付宝等付款方式,网站可选中文网页,提供中文客服支持。本月商家继续提供每日限量秒杀服务器月付30.62美元起,除了常规服务器外,商家美国/韩国/日本站群服务器、1-10...

随风云25元/月 ,德阳高防云服务器 2核2G 10M 75元/月 内蒙古三线BGP服务器 2核2G 5M

公司介绍成都随风云科技有限公司成立于2021年,是国内领先的互联网业务平台服务提供商。公司专注为用户提供低价高性能云计算产品,致力于云计算应用的易用性开发,并引导云计算在国内普及。目前公司研发以及运营云服务基础设施服务平台(IaaS),面向全球客户提供基于云计算的IT解决方案与客户服务,拥有丰富的国内BGP、双线高防、香港等优质的IDC资源。公司一直秉承”以人为本、客户为尊、永续创新&...

怎么把图片缩小为你推荐
ov单片机中psw中的ov的用法手机游戏排行榜2015安卓手机单机游戏2015年排行榜?网页解密急急急~~谁知道怎么让所有的网页都设密码?以及破解的办法啊? 谢谢了谁帮帮我啊主页改不了怎么改不了主页站长故事爱迪生发明东西的故事湖南商标注册湖南商标注册代办公司最新qq空间代码QQ空间代码快速美白好方法快速美白方法滚动代码来回滚动代码硬盘人上海人说“硬盘”是什么梗
万网域名空间 重庆服务器托管 韩国电信 免费静态空间 台湾谷歌地址 上海域名 seednet 1g内存 域名和空间 phpmyadmin配置 华为云服务登录 web服务器搭建 东莞idc 双线空间 免费个人主页 lamp的音标 实惠 谷歌搜索打不开 免费获得q币 windowsserver2008 更多