СµÜÏëʵÏÖÔÚÉÏ´«Í¼Æ¬Ê±,¼ÓÉÏˮӡ,²»ÖªµÀÔõôʵÏÖ,ÇëÓùýµÄÐÖµÜÖ¸µãÒ»¡¢¶þ
------½â¾ö·½°¸--------------------
ÒÔÇ°µÄÌù×Ó£¬²Î¿¼Ò»Ï°É
http://topic.csdn.net/t/20050402/15/3903402.html
------½â¾ö·½°¸--------------------
aspjpeg×é¼þºÜÈÝÒ×ʵÏÖ
------½â¾ö·½°¸--------------------
package net.csdn.xdj.servlet.d050403;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import org.apache.struts.upload.FormFile;
import java.io.*;
import net.csdn.xdj.model.d050403.Mark;
/**
* <p> ÉÏ´«´¦Àí£¬Action </p>
* <p> Title: community.csnd.net </p>
* <p> Description: javaÎÊÌâ½â´ð </p>
* <p> Copyright: Copyright (c) 2005 </p>
* <p> Company: ×ÔÓÉÈË </p>
* @author ÐíµÂ½¨£¨simonxuluo£©
* @version 1.0
*/
public class UploadImage
extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response) {
UploadAFB form = (UploadAFB) actionForm;
String theAction = form.getTheAction();
form.setTheAction( "uploadImage ");
if (theAction == null) {
theAction = " ";
}
else if (theAction.equals( "uploadImage ")) {
FormFile file = form.getTheFile();
File newFile = new File(form.getNewFile());
if (file == null || newFile == null) {
return mapping.getInputForward();
}
try {
ByteArrayOutputStream baos = Mark.manipulateImage( "ÐíµÂ½¨ ",
file.getFileData());
FileOutputStream fos = new FileOutputStream(newFile);
baos.writeTo(fos);
fos.close();
baos.close();
request.setAttribute( "message ", "ÉÏ´«³É¹¦ ");
return mapping.findForward( "response ");
}
catch (FileNotFoundException ex) {
// error handle
}
catch (IOException ex) {
// error handle
}
}
return mapping.getInputForward();
}
}