Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting a Blob from a Web Page

Status
Not open for further replies.

CRoberts

MIS
Apr 14, 1999
70
0
0
US
Hello. I have a requirement from a customer(and a Web programmer) that from a Web page that a supporting (can be a large Pdf or Word file) document is be inserted into the database as a Blob.

Our environment here is a Windows NT client, an Windows NT Web Server using Asp, and a 8.1.5 database located on a UNIX platform.

My question is, since I have not done anything like this, what is the simple approach needed to upload that document into the database? I would like to used a stored procedure if possible. Can I upload directly from the client having the asp feed the document into the stored procedure? Must I use a third party solution? Or is the only approach is to copy the file to the database server and use a DBMS_Lob package from a directory recognized by Oracle (via a CREATE DIRECTORY command). I am looking for simple, but any advise would be appreciated. Thank you.

 
I've not loaded BLobs into a DB but I have worked with Blobs inside the DB. I can say that you could only load 32K at a time (reading a raw into the procedure) so it may have to called several times with additional calls appending to the Blob and the first creating it.

Hope this is of some help,

Mike.
 
Maybe instead of using a blob, you could just keep the path and access the files using the path you have stored in your table. Just a suggestion.
 
Thank you. I have worked with Blobs and know that there is a 32k size limitation within PL/SQL. My problem is getting the document from the client's PC into the database. Do I need to do an FTP of the document into the database server? Once there a BFile and DBMS_LOB can be used to upload the document. But, can I do the upload directly? I can not use a Path using a BFile. Would be nice, but these are super secret legal documents that I have been mandated to hide within a database. These documents are not to be stored on a shared drive. Supposedly the documents can not even be stored temporarily on a server while being uploaded loaded into the database. Of course, my jaded response is if security is so necessary, why use a Web page and browser in the first place?
 
i am using LONGBLOB datatype in MYSQL for storing the 15 pages of MSWORD file. and i want to retrive it for displaying it in HTML file.

What is happening is the part of the text
gets stored but images do not, also the display of the text does not show
the full text, it shows only 255 characters.1) How can I display full 15
pages text? 2) If (1) is done then how can I display images embedded in
text.
I am displaying the columns of the table in a webbrowser using servlets and
mysql.

reply soon
wafia@urdip.res.in
 
I have use ASP to upload binary files directly into a BLOB column. The basic technique and code can be foud here:

I had to make some modifications to save it to the database but this should get you going.

Wafia, below is some code that will display the BLOB in an ASP after you upload it (for Oracle not mySQL).

<%@ Language=VBScript %>
<% Response.Buffer = True %>
<!--#include file=&quot;Connections/GTS_Conn3.asp&quot; -->

<% 'select BLOB
Set RS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.ActiveConnection = MM_GTS_Conn_String
rs.Source = &quot;SELECT filesize, filetype, filedata FROM test_uploads WHERE ROWNUM = 1 AND filename = '&quot; & Request(&quot;FileName&quot;) & &quot;'&quot;
rs.CursorType = 0
rs.CursorLocation = 3
rs.LockType = 3
RS.Open
%>

<% 'write binary file
Dim objBLOB
Dim FileLength
Dim NumBlocks
Dim LeftOver
Dim intLoop
Dim BlockSize

BlockSize = 500

Set objBLOB = rs(&quot;filedata&quot;)
FileLength = objBLOB.ActualSize
NumBlocks = CDbl(rs.fields.item(&quot;filesize&quot;).value) \ BlockSize
LeftOver = CDbl(rs.fields.item(&quot;filesize&quot;).value) Mod BlockSize
Response.Contenttype = rs(&quot;filetype&quot;)
Response.BinaryWrite objBLOB.GetChunk(LeftOver)
For intLoop = 1 To NumBlocks
Response.BinaryWrite objBLOB.GetChunk(BlockSize)
Next


Response.End
Set objBLob = Nothing
%>

<%
RS.Close
RS.ActiveConnection = Nothing
Set RS = Nothing
%>
<!--#include file=&quot;close_gts_conn.asp&quot; -->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top