Oracle three upload file techniques

  • 2020-05-15 02:26:17
  • OfStack

The ORACLE tutorial you are looking at is :Oracle3 upload file techniques.

There are several ways to upload files to a database or server file system in Oracle. The following three methods are mainly introduced here: the mod_plsql module of Oracle HTTP Server (OHS) provides the function of uploading files to a database via web page; Oracle 9iAS's tag library and Bean's file upload function; Upload files through the JDBC program.

1. The mod_plsql module of Oracle HTTP Server (OHS) provides the ability to upload files to the database via the web page

1. Create a document access table in the target mode for file upload


The CONTENT_TYPE table lists BLOB or long raw, but only has one column. Each uploaded file occupies a single row in the table, and you cannot upload multiple files to the same row in the table at the same time, which is the limitation of the mod_plsql module. Create a document table with the following and columns: Content_table.


2. Configure the document access table for DAD

After starting the database and OHS, create a blank database access descriptor. The gateway on the database access descriptor page USES document table information to upload/download documents to the database associated with this database access descriptor. All documents will be uploaded as BLOB by default. This default can be overridden by specifying a comma-delimited file extension in the Long Raw field. The * value of this field will enable all documents to be uploaded as Long Raw. Document access procedure "specifies the virtual path used to access the document." The "document access procedure" field specifies the procedure the gateway calls to process the document request. The default document table is specified as content_table.

3. Provides a file upload page where files are uploaded and viewed and downloaded using stored procedures.


4. Provide upload file browsing page

The file submitted in step 3 is automatically uploaded to the document table. The following procedure, WRITE_INFOS, records the uploaded file information. It is not necessary at all, but a comparison is made here.


After consulting the document table, you will find that the file has been uploaded, but there is an error in the upload time of the document table, which is inconsistent with the system time in the upload record. This may be an BUG of this function. If anyone has a solution or software patch to solve this problem, please let me know.

5. Provides page browsing for uploading files


This allows you to browse the files through the Web browser based on the mime_type type of the uploaded files.

This method of uploading files is the most simple, can support Chinese file names, support client file upload and download, can automatically identify the file type and calculate the file size.

[NextPage]

2. The tag library of Oracle 9iAS and the file upload function provided by Bean

in_file.jsp file provides the upload form, up_file.jsp lists the uploaded files, and dn_file.jsp file is the file you just uploaded. This method USES the graphical editor, simple and feasible, but does not support the Chinese file name, can realize the client file upload and download.

The following is the source program for in_file.jsp:


up_file. jsp source program:


dn_file. jsp source program:


3. Upload and download files via JDBC

By dividing the file upload file upload to BLOB or CLOB implementation, but this method does not support the client file upload, is very big, so the limitations by JDBC download function is in the server's local download download a program (not listed), so this method can only as 1 item of technology reference, not much practical value.

Blob_in_stream. jsp procedure is as follows:


Blob_w_stream. jsp program is as follows:

On 1 page


Related articles: