473,241 Members | 1,576 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

send a word document through POST using VB .net 2005

Hey guys, I have a question for you,
I have a setup where I'm sending files through the POST to a php web page, I
read the file contents, put that file contents as text into the POST string,
and send it on it's way.

it works perfectly for text files. However, I can't open a word document
like a text file and have it give me the result I need. I'm looking for a
way to just open a word document and get all the values in it like you would
if you opened it with notepad. any ideas? or any suggestions on how to
better send a non-text file through post? Thanks!
Jan 6 '06 #1
10 8903
You need to perform a http upload, whether from an asp.net page, or from an
application. PHP knows how to accept form data with attachments and word
docs need to go over the wire as complete files or you will lsoe all the
formatting. If you dont need it preserved as a word doc, use word
automation to open the doc and read its contents.

--
Regards

John Timney
Microsoft MVP

"Aj Blosser" <Aj*******@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
Hey guys, I have a question for you,
I have a setup where I'm sending files through the POST to a php web page,
I
read the file contents, put that file contents as text into the POST
string,
and send it on it's way.

it works perfectly for text files. However, I can't open a word document
like a text file and have it give me the result I need. I'm looking for a
way to just open a word document and get all the values in it like you
would
if you opened it with notepad. any ideas? or any suggestions on how to
better send a non-text file through post? Thanks!

Jan 6 '06 #2
Right, but is there some kind of upload function? I need to do this from an
application as It's part of an MS word addin. as of now I'm using
MSXML2.ServerXMLHTTP to send the POST request, but what I can't figure out is
how to send the file over. I'm assuming that the "body" parameter of the
send method is for the POST query string, this might be my problem, but I
can't find any specifics on this.

"John Timney ( MVP )" wrote:
You need to perform a http upload, whether from an asp.net page, or from an
application. PHP knows how to accept form data with attachments and word
docs need to go over the wire as complete files or you will lsoe all the
formatting. If you dont need it preserved as a word doc, use word
automation to open the doc and read its contents.

--
Regards

John Timney
Microsoft MVP

"Aj Blosser" <Aj*******@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
Hey guys, I have a question for you,
I have a setup where I'm sending files through the POST to a php web page,
I
read the file contents, put that file contents as text into the POST
string,
and send it on it's way.

it works perfectly for text files. However, I can't open a word document
like a text file and have it give me the result I need. I'm looking for a
way to just open a word document and get all the values in it like you
would
if you opened it with notepad. any ideas? or any suggestions on how to
better send a non-text file through post? Thanks!


Jan 6 '06 #3
Here's the code I'm using btw:

Dim http As New MSXML2.ServerXMLHTTP

'Create XMLHTTP/ServerXMLHTTP/WinHttprequest object
'You can use any of these three objects.
' http = CreateObject("WinHttp.WinHttprequest.5")
' http = CreateObject("MSXML2.XMLHTTP")
http = CreateObject("MSXML2.ServerXMLHTTP")

'Open URL As POST request
http.open("POST", URL, False)

'Set Content-Type header
http.setRequestHeader("Content-Type", "multipart/form-data;
boundary=" + Boundary)
http.setRequestHeader("name", "datafile")
http.setRequestHeader("filename", "ocxtest.txt")
http.setRequestHeader("Content-Disposition",
"attachment;filename=mitchell-pres.zip")

'Send the form data To URL As POST binary request

Dim d As String


d = "--" + Boundary + vbCrLf + "Content-Disposition: form-data;
name='file';" + " filename=OCXTEST.DOC " + vbCrLf + "Content-Type:
multipart/form-data;" + vbCrLf + vbCrLf
' http.send(d)
http.send(FormData)

d = vbCrLf + "--" + Boundary + "--" + vbCrLf
'http.send(d)
MsgBox(FormData)


'Get a result of the script which has received upload
WinHTTPPostRequest = http.responseText
MsgBox(http.responseText)
Jan 6 '06 #4
take a read of this - you may be able to get it working from within word.
You should almost certainly be able to use the IE object example from within
word.

http://www.motobit.com/tips/detpg_post-binary-data-url/

--
Regards

John Timney
Microsoft MVP

"Aj Blosser" <Aj*******@discussions.microsoft.com> wrote in message
news:C1**********************************@microsof t.com...
Right, but is there some kind of upload function? I need to do this from
an
application as It's part of an MS word addin. as of now I'm using
MSXML2.ServerXMLHTTP to send the POST request, but what I can't figure out
is
how to send the file over. I'm assuming that the "body" parameter of the
send method is for the POST query string, this might be my problem, but I
can't find any specifics on this.

"John Timney ( MVP )" wrote:
You need to perform a http upload, whether from an asp.net page, or from
an
application. PHP knows how to accept form data with attachments and word
docs need to go over the wire as complete files or you will lsoe all the
formatting. If you dont need it preserved as a word doc, use word
automation to open the doc and read its contents.

--
Regards

John Timney
Microsoft MVP

"Aj Blosser" <Aj*******@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
> Hey guys, I have a question for you,
> I have a setup where I'm sending files through the POST to a php web
> page,
> I
> read the file contents, put that file contents as text into the POST
> string,
> and send it on it's way.
>
> it works perfectly for text files. However, I can't open a word
> document
> like a text file and have it give me the result I need. I'm looking
> for a
> way to just open a word document and get all the values in it like you
> would
> if you opened it with notepad. any ideas? or any suggestions on how to
> better send a non-text file through post? Thanks!


Jan 6 '06 #5
Hello Aj,
Hey guys, I have a question for you,
I have a setup where I'm sending files through the POST to a php web
page, I
read the file contents, put that file contents as text into the POST
string,
and send it on it's way.
it works perfectly for text files. However, I can't open a word
document like a text file and have it give me the result I need. I'm
looking for a way to just open a word document and get all the values
in it like you would if you opened it with notepad. any ideas? or any
suggestions on how to better send a non-text file through post?


There's really no difference between text and binary data (which is a false
notion anyway): Open the file using a FileStream, load its contents to a
buffer in memory (e.g. a MemoryStream), and post these bytes. If buffernig
in memory isn't required, you can copy the bytes read from the FileStream
directly to your NetworkStream.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Jan 7 '06 #6
See, the problem is, when I read the word doc into a filestream,
all I get out of that is:

using .readline 5 or 6 ascii characters. ?'s and blocks.
using .read I get close to the right filesize, but it's all numbers
and using .basestream.readbyte it locks up and stalls on me.

any suggestions?

"Joerg Jooss" wrote:
Hello Aj,
Hey guys, I have a question for you,
I have a setup where I'm sending files through the POST to a php web
page, I
read the file contents, put that file contents as text into the POST
string,
and send it on it's way.
it works perfectly for text files. However, I can't open a word
document like a text file and have it give me the result I need. I'm
looking for a way to just open a word document and get all the values
in it like you would if you opened it with notepad. any ideas? or any
suggestions on how to better send a non-text file through post?


There's really no difference between text and binary data (which is a false
notion anyway): Open the file using a FileStream, load its contents to a
buffer in memory (e.g. a MemoryStream), and post these bytes. If buffernig
in memory isn't required, you can copy the bytes read from the FileStream
directly to your NetworkStream.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de

Jan 7 '06 #7
Hello Aj,
See, the problem is, when I read the word doc into a filestream,
all I get out of that is:
using .readline 5 or 6 ascii characters. ?'s and blocks.
Readline() is a StreamReader method. That won't work, as Word files are binary
content.
using .read I get close to the right filesize, but it's all numbers


*Bytes*. But that's what you want! You cannot get a meaningful string representation
of Word document.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Jan 7 '06 #8
I guess that's where my confusion is.

So is what your saying, I need to find a way in PHP to convert the bytes to
binary?

"Joerg Jooss" wrote:
Hello Aj,
See, the problem is, when I read the word doc into a filestream,
all I get out of that is:
using .readline 5 or 6 ascii characters. ?'s and blocks.


Readline() is a StreamReader method. That won't work, as Word files are binary
content.
using .read I get close to the right filesize, but it's all numbers


*Bytes*. But that's what you want! You cannot get a meaningful string representation
of Word document.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de

Jan 7 '06 #9
Hello Aj,
I guess that's where my confusion is.

So is what your saying, I need to find a way in PHP to convert the
bytes to binary?


No, the bytes *are* binary. Just save them in your PHP application to disk
or whatever you need to do.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Jan 7 '06 #10
That's what I've been doing, but when I save it as a word doc, and try to
open it up in word, I just get all the bytes as numbers.

Also, if I open a word doc up in note pad pre-sending it has a lot more than
just numbers in it. The word doc that gets sent, ONLY has numbers in it.

"Joerg Jooss" wrote:
Hello Aj,
I guess that's where my confusion is.

So is what your saying, I need to find a way in PHP to convert the
bytes to binary?


No, the bytes *are* binary. Just save them in your PHP application to disk
or whatever you need to do.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de

Jan 7 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Caversham | last post by:
Is there any macro / other tool - free or commercial - that can split long Word docs into multiple XHTML pages? Any comments on the quality/effectiveness of suitable products also welcomed.
5
by: mark kurten | last post by:
i have a requirement to send a soap message to a web service. i'm familiar with the soap toolkit using vb. i need to generate a xml document which i think i can do, but i don't know how to...
4
by: Otis Hunter | last post by:
I have been given an Access Database which contains a table that has an OLE object field that contains a Word document. That table contains hundreds of records. I would like to find out how I can...
10
by: Neil | last post by:
An article at http://news.com.com/2100-1012-991694.html?tag=fd_top states: "XML would allow easier interchange of data generated in Office documents with back-end systems or existing Web...
7
by: Andy Davis | last post by:
I have a table of data in Access 2002 which is used as the source table for a mail merge document using Word 2002 on my clients PC. The data is transferred OK but I've noticed that any dates which...
12
by: Rob Nicholson | last post by:
We've implemented functionality to allow a user to download a document (any document type) from the IIS server using the following code: Response.Clear() Response.ContentType =...
0
by: Niyazi | last post by:
Hi, I created application that store the data in SQL SERVER that reside on network. The client also use this application to access the resources provided with application. But is the client want...
0
southoz
by: southoz | last post by:
Good ay all , I'm fairly new to access(a little over 5 weeks now). Since I'v started I have picked up a lot of useful information from forums such as this and in doing so will share that information...
4
by: =?Utf-8?B?QXJ0?= | last post by:
Hello, I saw this posting and it is the closest place to ask this question. I am simply trying to create a Word document from a VB application I am wrting with Visual Studio 2005. I cut a...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.