Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JAVAÖ®"ÎļþÉÏ´«"

<form name="UploadForm" enctype="multipart/form-data" method="post" action="upLoadImage.do">
<input type="file" name="File1" size="11" maxlength="20"/><input type="submit"value="ÉÏ ´«"/>
</form>  
  String path="images\\product\\";
String temp=this.getServlet().getServletContext().getRealPath("/")+"temp"; //ÁÙʱĿ¼
String loadpath=this.getServlet().getServletContext().getRealPath("/")+path; //ÉÏ´«Îļþ´æ·ÅĿ¼

DiskFileUpload fu = new DiskFileUpload();
fu.setSizeMax(10*1024*1024); // ÉèÖÃÔÊÐíÓû§ÉÏ´«Îļþ´óС,µ¥Î»:×Ö½Ú
fu.setSizeThreshold(4096); // ÉèÖÃ×î¶àÖ»ÔÊÐíÔÚÄÚ´æÖд洢µÄÊý¾Ý,µ¥Î»:×Ö½Ú
fu.setRepositoryPath(temp); // ÉèÖÃÒ»µ©Îļþ´óС³¬¹ýgetSizeThreshold()µÄֵʱÊý¾Ý´æ·ÅÔÚÓ²Å̵ÄĿ¼

//¿ªÊ¼¶ÁÈ¡ÉÏ´«ÐÅÏ¢
List fileItems = fu.parseRequest(request);

System.out.println(fileItems.size());//Êä³öÉÏ´«ÎļþÐÅÏ¢


Iterator iter = fileItems.iterator(); // ÒÀ´Î´¦Àíÿ¸öÉÏ´«µÄÎļþ
while (iter.hasNext())
{
FileItem item = (FileItem) iter.next();// ºöÂÔÆäËû²»ÊÇÎļþÓòµÄËùÓÐ±íµ¥ÐÅÏ¢
if (!item.isFormField())
{
String name = item.getName();//»ñÈ¡ÉÏ´«ÎļþÃû,°üÀ¨Â·¾¶
name=name.substring(name.lastIndexOf("\\")+1);//´Óȫ·¾¶ÖÐÌáÈ¡ÎļþÃû
long size = item.getSize();
if((name==null||name.equals("")) && size==0){
request.setAttribute("uploadmessage","ÉÏ´«Í¼Æ¬Ê§°Ü!");
return mapping.findForward("product");
}
File fNew= new File(loadpath, name);
item.write(fNew);
request.setAttribute("uploadmessage","ÉÏ´«Í¼Æ¬³É¹¦!");
HttpSession session=request.getSession();
session.setAttribute("path",(path+fNew.getName()).replace("\\","/"));
System.out.println((path+fNew.getName()).replace("\\","/"));
}
}


Ïà¹ØÎĵµ£º

javaÖÐhashcode()ºÍequals()µÄÏê½â(ת)

Ô­ÌùµØÖ·http://www.javaeye.com/topic/257191
½ñÌìÏÂÎçÑо¿ÁË°ëÌìhashcode()ºÍequals()·½·¨£¬ÖÕÓÚÓÐÁËÒ»µãµãµÄÃ÷°×£¬Ð´ÏÂÀ´Óë´ó¼Ò·ÖÏí£¨zhaoxudong
2008.10.23Íí21.36£©¡£
1. Ê×ÏÈequals()ºÍhashcode()ÕâÁ½¸ö·½·¨¶¼ÊÇ´ÓobjectÀàÖм̳йýÀ´µÄ¡£
equals()·½·¨ÔÚobjectÀàÖж¨ÒåÈçÏ£º
  public boolean equals( ......

java»·¾³´î½¨

×î½üÎÒÓöµ½ºÜ¶àjava¿ª·¢µÄÐÂÈË£¬°üÀ¨ºÜ×ÔÈÏΪ²»ÊÇÐÂÈ˵ÄÈ˸ù±¾¾Í²»»á×Ô¼º´î½¨Ò»¸öÍêÕûµÄ¿ª·¢»·¾³£¬Òò´ËÏëд´ËÎÄ£¬Ï£¶ÔËûÃÇÓÐËù°ïÖú£¬½â³ýËûÃǵÄһЩ¿ª·¢À§»ó£¬¸üºÃµÄÁ˽âjava.
Ò»¡¢windowsÏ¿ª·¢»·¾³µÄ´î½¨
1¡¢´Óhttp://java.sun.com/ÉÏÏÂÔØwindowsƽ̨µÄJDK,²¢°²×°¡£¼ÙÉ谲װĿ¼Ϊ£ºC:\jdk6.0
2¡¢É趨Ïà¹Ø»·¾³Á¿£¨ÒÔwi ......

ʹÓÿªÔ´²úÆ·´î½¨java¿ª·¢»·¾³

Ô­·¢±íÓÚhttp://saharabear.javaeye.com
 ºÍhttp://www.haulynjason.net(Ó¢)
ͬʱ·¢±íÔÚÕâÀï.
ÔÚÎÒÖÜΧ,ÓкܶàÈËÊÇJava³ÌÐòÔ±»òÕß¼ÆËã»úרҵµÄѧÉú.ÓÐʱ,ÎÒ°ïËûÃǵ÷ÊÔ³ÌÐòµÄʱºò,·¢ÏÖËûÃǵĻúÆ÷ÉÏ×ÜÊÇ°²×°×źܶàûÓÐÊÚȨµÄ¹¤¾ß,±ÈÈçµÁ°æµÄ
windows,ûÓÐLicenseµÄMyEclipseµÈ,ÉõÖÁÓÐһЩÈË·Ö²»ÇåeclipseºÍmyeclipse ......

Java ²¢·¢Ñ§Ï°


Ò»¡¢´´½¨ÈÎÎñ
 
ÈÎÎñ¿ÉÒÔÀí½âΪһ¶Î¶ÀÁ¢Ö´ÐеĴúÂ룬ËüÍê³ÉÒ»¶¨µÄ¹¦ÄÜ¡£
ÔÚJava 5¼°ÒÔÉÏ°æ±¾Öв»½ö¿ÉÒÔÀûÓà Runnable½Ó¿Ú£¬»¹¿ÉÒÔÀûÓÃCallable½Ó¿Ú¡£
    Á½ÖÖÈÎÎñµÄÇø±ð£ºRunnable µÄrun()·½·¨Íê³ÉµÄÈÎÎñÊÇûÓзµ»ØÖµµÄ - void
    ¶øCallable µÄcall()·½·¨Íê³ÉµÄÈÎÎñÊÇÓзµ»ØÖ ......

ÓÃjava±àд¶àÏß³Ìftp¶ÏµãÏÂÔØÎļþ³ÌÐò


×÷Õß
:
ÀîÖ¾ÌÎ
ÓÊÏäµØÖ·
:lizhitao67116961@163.com
ÉîÛÚÓÅÍø¿Æ¼¼ÓÐÏÞ¹«Ë¾
 
Ç°¼¸Ìì¿´µ½ÓÐijλÍøÓÑдÁËÓÃhttp½øÐжϵãÏÂÔØÎļþ£¬µ«ÊÇÍøÉÏûÓп´µ½ftp¶ÏµãÏÂÔصÄÎÄÕ»ò´úÂ룬ÏÖÔÚ±¾ÈËдÁËһϡ£¾­¹ý²âÊÔûÓÐÎÊÌâ¡£Çë´ó¼Ò¶à¶àÖ¸½Ì¡£ÈçÓÐÊ詵ĵط½Çë¸÷λ¼¼ÊõÓÑÈËÖ¸³ö¡£±¾È˲»Ê¤¸Ð¼¤¡£
 
package
test.d ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ