Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Is it possible to use Msxml2.XMLHTTP to upload a text file?

Reply
Thread Tools

Is it possible to use Msxml2.XMLHTTP to upload a text file?

 
 
Eric
Guest
Posts: n/a
 
      12-23-2003
I have a form with an INPUT type=file in it.
I have another button that calls a function to exercise the oHTTP below.

I think I need to open with the path of the CGI script on the server.
What should the send have in it?

oHTTP.open("POST", ??????????, false);
oHTTP.send(????????????????????);

Thanks.
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      12-24-2003


Eric wrote:

> I have a form with an INPUT type=file in it.


Then to upload the file let the user use an
<input type="submit">
button.
> I have another button that calls a function to exercise the oHTTP below.
>
> I think I need to open with the path of the CGI script on the server.
> What should the send have in it?
>
> oHTTP.open("POST", ??????????, false);
> oHTTP.send(????????????????????);


Msxml2.XMLHTTP can upload the contents of a text file, for instance you
can send a HTTP POST request where the request body is the file content:

var fso = new ActiveXObject('Scripting.FileSystemObject');
var stream = fso.OpenTextFile('test20031223.txt', 1, false);
var fileContent = stream.ReadAll();
var httpRequest = new ActiveXObject('Msxml2.XMLHTTP');
httpRequest.open('POST', 'http://host/dir/file.asp', false);
httpRequest.setRequestHeader('Content-Type', 'text/plain');
httpRequest.setRequestHeader('Content-Length', fileContent.length);
httpRequest.send(fileContent);

The only problem is that usual from script within a HTML page loaded via
HTTP from a web server security restrictions will not allow you to read
files from the file system of the client.

--

Martin Honnen
http://JavaScript.FAQTs.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File upload from client application (non-form based upload) stuart@microsoft.com Python 1 11-25-2006 12:14 AM
Re: text file search to text file output possible? Mitch Computer Support 0 10-06-2006 11:15 PM
Upload a file without file Upload control - ASP.Net =?Utf-8?B?U2FyYXY=?= ASP .Net 3 08-03-2005 01:09 AM
How to detect sizeof upload in order to show status of browser file upload? Heather Fraser Java 0 07-05-2004 12:35 AM
Upload Excel with Macros using HTML File Upload Prakash ASP General 3 11-12-2003 04:26 AM



Advertisments