Rev 5958 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%@LANGUAGE="VBSCRIPT"%><%'=====================================================' NEW Upload PDF' --- PROCESS FORM ---'=====================================================%><%Option explicit' Good idea to set when using redirectResponse.Expires = 0 ' always load the page, dont store%><!--#include file="common/config.asp"--><!--#include file="common/globals.asp"--><!--#include file="common/formating.asp"--><!--#include file="common/qstr.asp"--><!--#include file="common/common_subs.asp"--><!--#include file="common/common_dbedit.asp"--><!--#include file="upload/clsUpload.asp"--><%' Set rfile parameter. This is a return page after LoginCall objPMod.StoreParameter ( "rfile", "Bom_Home.asp" )'------------ ACCESS CONTROL ------------------%><!--#include file="_access_control_general.asp"--><%'------------ Variable Definition -------------Dim objUploadDim sFileName'------------ Constants Declaration -----------'------------ Variable Init -------------------Set objUpload = New clsUpload'parPv_id = objUpload.Fields("pv_id").Value'----------------------------------------------%><%'----------------------- MAIN LINE ---------------------------'--- Process submition ---If (objUpload.Fields("bom_id").Value <> "") Then' Compile path to save file toIf instr(Request.ServerVariables("HTTP_USER_AGENT"), "MSIE") > 0 ThensFileName = objUpload.Fields("results_file").FileNameElsesFileName = objUpload.Fields("results_file").FilePathEnd If'' Save file name into the BOMS table for backward compatability'OraSession.BeginTransOraDatabase.ExecuteSQL "UPDATE BOMS SET PDF_ATTACHMENT_PATH='"& sFileName &"' WHERE BOM_ID ="& objUpload.Fields("bom_id").ValueOraSession.CommitTrans'' Save the binary file into the Database as a blob'Dim OraParametersDim OraBlobDim PartImageDim amount_writtenSet OraParameters = OraDatabase.ParametersOraParameters.Add "PartImage", Empty,ORAPARM_OUTPUT, ORATYPE_BLOB'BeginTrans needs to be called since LOB locators become invalid after the ExecuteSQL callOn Error Resume NextOraSession.BeginTrans' Only retain one entry, so delete any that existOraDatabase.ExecuteSQL "DELETE FROM BOM_ATTACHMENTS WHERE BOM_ID="& objUpload.Fields("bom_id").Value' Create the entry with an empty blobOraDatabase.ExecuteSQL ("insert into BOM_ATTACHMENTS (BOM_ID, LENGTH, CONTENTTYPE, NAME, DATA) values ("&_objUpload.Fields("bom_id").Value &","&_objUpload("results_file").Length &",'"&_objUpload("results_file").ContentType &"','"&_sFileName & "', EMPTY_BLOB()) RETURNING DATA INTO :PartImage")Set PartImage = OraDatabase.Parameters("PARTIMAGE").Value'' Need to send the data in chuncks' Not sure what the chunk limit is, but we will try 1Meg lumpsDim dataDim dataLenDim dataIndexDim sendSizeDim sendTypedata = objUpload("results_file").BLOBdataLen = objUpload("results_file").LengthdataIndex = 0sendSize = 1048576sendSize = 1024sendType = ORALOB_FIRST_PIECESet OraBlob = OraDatabase.Parameters("PartImage").ValueDo While dataLen > 0If Err.number <> 0 Then Exit DoIf dataIndex = 0 ThenIf sendSize > dataLen ThensendSize = dataLensendType = ORALOB_ONE_PIECEElsesendType = ORALOB_FIRST_PIECEEnd IfElseIf sendSize > dataLen ThensendSize = dataLensendType = ORALOB_LAST_PIECEEnd IfEnd Ifamount_written = OraBlob.Write(MidB( data, 1+dataIndex, sendSize), sendSize , sendType)dataLen = dataLen - sendSizedataIndex = dataIndex + sendSizesendType = ORALOB_NEXT_PIECELoop' Rollback or commit the transactionIf Err.number <> 0 ThenOraSession.RollbackElseOraSession.CommitTransEnd If' Either update the parent display or display an error messageIf Err.number <> 0 ThenCall RaiseMsgInParent ( enum_MSG_ERROR, "Upload is not completed.<br>" & Err.description )ElseCall OpenInParentWindow ("Bom_Home.asp?bom_id="& objUpload.Fields("bom_id").Value)End IfSet objUpload = NothingCall CloseWindowElseResponse.write "Some mandatory parameters are missing!" & "<br>" 'TODOResponse.write QSTR_AllEnd IfCall Destroy_All_Objects%>