Upload a binary file with vb.net from an xml node - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Upload a binary file with vb.net from an xml node

orlijaorlija Posts: 1Member
Hi experts.

I'm trying to upload binary file into an oracle blob field. I retrieve the binary file from an XML document loaded in memory. I'll try to explain this in detail:

1) A page builds an XMLDocument with client code. In a node of this document, it sets the type to binary and attach a local filesystem document. Then, assigns the value to an hidden input field and sends it to itself
2) This page receives the post data, selects the binary content of the xml node and try to insert the binary data into the blob field (server side code).

I show you the code of this two parts:

1) This part works propertly (I only shows it for if it helps you)

function creaObjecte()
// create ADO-stream Object
var ado_stream = new ActiveXObject("ADODB.Stream");

// create XML document with default header and primary node
var xml_dom = new ActiveXObject("MSXML2.DOMDocument");
xml_dom.loadXML('<?xml version="1.0" ?> ');
// specify namespaces datatypes
xml_dom.documentElement.setAttribute("xmlns:dt", "urn:schemas-microsoft-com:datatypes");

// create a new node and set binary content
var l_node1 = xml_dom.createElement("file1");
l_node1.dataType = "bin.base64";
// open stream object and read source file
ado_stream.Type = 1; // 1=adTypeBinary
// store file content into XML node
l_node1.nodeTypedValue = ado_stream.Read(-1); // -1=adReadAll

document.getElementById("p_arxiu").value = xml_dom.xml;

2) I'm using this code. It inserts data into the blob, but doesn't inserts the binary data correctly (I use a pl/sql procedure for download the binary fields for the moment)

Protected Sub btnenviar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnenviar.Click

' Cadena de connexi
Sign In or Register to comment.