<%@LANGUAGE="VBSCRIPT"%> <% '===================================================== ' NEW Upload PDF ' --- PROCESS FORM --- '===================================================== %> <% Option explicit ' Good idea to set when using redirect Response.Expires = 0 ' always load the page, dont store %> <% ' Set rfile parameter. This is a return page after Login Call objPMod.StoreParameter ( "rfile", "Bom_Home.asp" ) '------------ ACCESS CONTROL ------------------ %> <% '------------ Variable Definition ------------- Dim objUpload Dim 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 to If instr(Request.ServerVariables("HTTP_USER_AGENT"), "MSIE") > 0 Then sFileName = objUpload.Fields("results_file").FileName Else sFileName = objUpload.Fields("results_file").FilePath End If ' ' Save file name into the BOMS table for backward compatability ' OraSession.BeginTrans OraDatabase.ExecuteSQL "UPDATE BOMS SET PDF_ATTACHMENT_PATH='"& sFileName &"' WHERE BOM_ID ="& objUpload.Fields("bom_id").Value OraSession.CommitTrans ' ' Save the binary file into the Database as a blob ' Dim OraParameters Dim OraBlob Dim PartImage Dim amount_written Set OraParameters = OraDatabase.Parameters OraParameters.Add "PartImage", Empty,ORAPARM_OUTPUT, ORATYPE_BLOB 'BeginTrans needs to be called since LOB locators become invalid after the ExecuteSQL call On Error Resume Next OraSession.BeginTrans ' Only retain one entry, so delete any that exist OraDatabase.ExecuteSQL "DELETE FROM BOM_ATTACHMENTS WHERE BOM_ID="& objUpload.Fields("bom_id").Value ' Create the entry with an empty blob OraDatabase.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 lumps Dim data Dim dataLen Dim dataIndex Dim sendSize Dim sendType data = objUpload("results_file").BLOB dataLen = objUpload("results_file").Length dataIndex = 0 sendSize = 1048576 sendSize = 1024 sendType = ORALOB_FIRST_PIECE Set OraBlob = OraDatabase.Parameters("PartImage").Value Do While dataLen > 0 If Err.number <> 0 Then Exit Do If dataIndex = 0 Then If sendSize > dataLen Then sendSize = dataLen sendType = ORALOB_ONE_PIECE Else sendType = ORALOB_FIRST_PIECE End If Else If sendSize > dataLen Then sendSize = dataLen sendType = ORALOB_LAST_PIECE End If End If amount_written = OraBlob.Write(MidB( data, 1+dataIndex, sendSize), sendSize , sendType) dataLen = dataLen - sendSize dataIndex = dataIndex + sendSize sendType = ORALOB_NEXT_PIECE Loop ' Rollback or commit the transaction If Err.number <> 0 Then OraSession.Rollback Else OraSession.CommitTrans End If ' Either update the parent display or display an error message If Err.number <> 0 Then Call RaiseMsgInParent ( enum_MSG_ERROR, "Upload is not completed.
" & Err.description ) Else Call OpenInParentWindow ("Bom_Home.asp?bom_id="& objUpload.Fields("bom_id").Value) End If Set objUpload = Nothing Call CloseWindow Else Response.write "Some mandatory parameters are missing!" & "
" 'TODO Response.write QSTR_All End If Call Destroy_All_Objects %>