oracle中有多种方法可以向数据库或服务器文件系统上载文件,这里主要介绍如下三种:oracle http server(ohs)的mod_plsql模块提供通过web页面向数据库上载文件的功能;oracle 9ias的标签库和bean提供的文件上载功能;通过jdbc程序上载文件。
一、oracle http server(ohs)的mod_plsql模块提供通过web页面向数据库上载文件的功能
1.在文件上载的目标模式中建立文档访问表
| create table [table_name] ( name varchar2(256) unique not null, mime_type varchar2(128), doc_size number, dad_charset varchar2(128), last_updated date, content_type varchar2(128), [content_column_name] [content_column_type] [ , [content_column_name] [content_column_type]] ); |
| name varchar(128) unique not null, mime_type varchar(128), doc_size number, dad_charset varchar(128), last_updated date, content_type varchar(128), content long raw, blob_content blob ; |
| create or replace procedure "zyfileup"."in_file" is begin htp.prn(' <html> <head> <title>file upload</title> </head> <body bgcolor="#c0c0c0"> <form enctype="multipart/form-data" action="/pls/upfile/write_infos" method="post"> <p><b><font size="5" color="#800080">指定上载文件</font></b></p> <hr> <p> <b>标题:<textarea rows="3" name="filetitle" cols="100" style="background-color: #008080; color: #ffffff"></textarea> <br> <b>类别:<input type="text" name="filesort" size="130" style="background-color: #008080; color: #ffffff"> <br> <b>作者:<input type="text" name="author" size="130" style="background-color: #008080; color: #ffffff"> <br> <b>小类:<input type="text" name="localsort" size="130" style="background-color: #008080; color: #ffffff"> <br> <b>摘要:<textarea rows="5" name="abstract" cols="130" style="background-color: #008080; color: #ffffff"></textarea> <br> <b>文章1:<input type="file" name="up_file" size="110" style="background-color: #008080; color: #ffffff"> <br> <b>文章2:<input type="file" name="up_file" size="110" style="background-color: #008080; color: #ffffff"> <br> <b>文章3:<input type="file" name="up_file" size="110" style="background-color: #008080; color: #ffffff"> <br> <b>文章4:<input type="file" name="up_file" size="110" style="background-color: #008080; color: #ffffff"> <br> </b></b></b></b></b></b></b></b></b></b> </p><hr><p><b> <line> <input type="submit" value="提交"> <input type="reset" value="全部重写"> </p> </form> </body> </html> '); end; |
| create or replace procedure "zyfileup"."write_infos" ( filetitle in varchar2, up_file in owa.vc_arr, filesort in varchar2, author in varchar2, abstract in varchar2, localsort in varchar2 ) is i number:=1; begin htp.htmlopen; htp.headopen; htp.title('file uploaded'); htp.headclose; htp.bodyopen; htp.header(1, 'upload status'); while true loop begin htp.prn('uploaded ' up_file(i) ' successfully !'); htp.prn('<br>'); htp.prn('<a href="/pls/upfile/downfile?upfilename='); htp.prn(utl_url.escape(up_file(i),true,'gbk')); htp.prn('" target="_blank">open this file !</a>'); htp.prn('<br>'); insert into "zyfileup"."file_table" values(filetitle,up_file(i),filesort,author,sysdate(),abstract,localsort); commit; i:=i+1; exception when no_data_found then exit; end; end loop; htp.line; htp.print('uploaded successfully !'); htp.bodyclose; htp.htmlclose; end; |
| create or replace procedure "zyfileup"."downfile" (upfilename in varchar2) is mimetype varchar2(100); myblob blob; begin select mime_type,blob_content into mimetype,myblob from zyfileup.content_table where name = upfilename; owa_util.mime_header(mimetype, true); sys.wpg_docload.download_file(myblob); end; |
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器