用JSP写出FileUpload上传小程序


void write(Java.io.File file)
    A convenience method to write an uploaded item to disk.

    而这里的是String!!!

    Constructor Summary
    File(File parent, String child)
    Creates a new File instance from a parent abstract pathname and a child pathname string.
    File(String pathname)
    Creates a new File instance by converting the given pathname string into an abstract pathname.
    File(String parent, String child)
    Creates a new File instance from a parent pathname string and a child pathname string.
    File(URI uri)
    Creates a new File instance by converting the given file: URI into an abstract pathname.
    我修改了这句为两句:

    File writeFile=new File("F:\\public",name);
    fi.write(writeFile);
    这样这个上传程序终于可以工作了!(一会有源代码,上传一个文件的)

    还有这里的"" 都是""(输入法问题),如果粘贴过来要一个个修改,不知道怎么回事情,网上的代码总是有一点让人难以琢磨的错误而不能运行!所以网上的东西只能参考理解之后再自己写!


    其它过程:


    1.upload
    B 端的上传
    1)

    upload目录:
    <form action="getUpload.JSP" enctype="multipart/form-data" method="POST">
    这里oc4j 的目录和 tomcat 的目录可是服务器硬盘上真实存在的任意目录!
    2)upload method.
    请输入要上传的文件:<input type="FILE" name="file"/>
    2.get
    S端读取:
    1).request.getInputStream 进行分析
    public ServletInputStream getInputStream() throws java.io.IOException

    2).Jakarta 通用库


    3.download


    temp sql:
    create table upload(
    name varchar2(16) primary key not null,
    content clob );
    commit;
    server 端接受文件上传, 下载commons-fileupload-1.0, http://jakarta.apache.org/commons/fileupload/
    说明:
    Commons是 Apache开放源代码组织中的一个Java子项目,该项目主要涉及一些开发中常用的模块,例如文件上传、命令行处理、数据库连接池、 XML配置文件处理等。这些项目集合了来自世界各地软件工程师的心血,其性能、稳定性等方面都经受得住实际应用的考验。有效地利用这些项目将会给开发带来 显而易见的效果。Fileupload就是其中用来处理HTTP文件上传的子项目。本文主要介绍如何使用Fileupload来处理浏览器提交到服务器的 文件信息。

    PS:一般下载的*.jar 文件都是拷贝到Tomcat 5.5\common\lib里面

    另外, 由于Fileupload子项目同时要用到另外一个项目commons-Beanutils,所以必须下载Beanutils,并将解压后的文件commons-beanutils.jar拷贝到{$TOMCAT}/common/lib目录下

 

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3