I am not sure where to post this topic but I though this section is the right one.

I have a large amount of data in a MS word file. Basically, I want to automate the posting of this data into my website through the normal form of posting topics into my website.

Is there any way to do that?

Recommended Answers

All 2 Replies

Using any program that can use sockets you can do this. If you have php installed on your computer then that's easy. I have done it with Game Maker (using 39dll) before.

What you need to do is read the file (word doc) into your program. (You may need to convert it to HTML or something...) Lets assume your using PHP. Use the fopen() function to read the file into a variable, say $file_content .

Then you want to make a socket connection to your website server: $pointer = fsockopen("www.yourdomain.com",80); And then write a HTTP request containing the data. This is what your internet browser does when you submit a form. It should look something like this:

POST /submit.php HTTP/1.1
Host: www.yourdomain.com
Connection-length: 24
Connection: close

content=Content of file.

Each line must end in "\r\n" (PHP notation) and an empty line represents the end of the header and the start of the content.

The above would be the result of submitting the following form:

<form action="www.yourdomain.com/submit.php" method="POST">
  <input type="text" name="content" value="Content of file." />
  <!-- submit etc. -->
</form>

You then use fputs() to "write" the request to your server and fgets() to "read" the response from your server (which in this case isn't as crucial).

So, load file, connect to server, construct a correct HTTP request, send it, retrieve the reply to your request to make sure it all went ok.

thank you very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.