473,394 Members | 1,714 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,394 software developers and data experts.

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

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.
Jul 20 '05 #1
1 8459


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/

Jul 20 '05 #2

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

Similar topics

3
by: Dan Sikorsky | last post by:
Uploading from browser to server using Msxml2.XMLHTTP takes a long time about 15 minutes for a 1.5MB file at 37.2Kbps, although it does get there. Is there anyway to speed things up? here's the...
2
by: Sergiusz Michalski | last post by:
Hallo!! According to my previous post with popups hanging, now I'm trying to bypass this strange behaviour using loading JavaScript image not by image.src=URL but straight away from stream using...
2
by: Michael Christensen | last post by:
Hi How do I send an input-param to my web service with MSXML2.ServerXMLHTTP? Can this be done without the soap-toolkit? Can't find anything about it - looking forward getting some help :-)...
0
by: | last post by:
///======================in C# writeSession.aspx ///Session("loginID") == "tmp"; MSXML2.XMLHTTPClass xmlHttp = new XMLHTTPClass(); try { XmlDocument xmlDom = new XmlDocument();...
1
by: Raúl Martín | last post by:
I´ve a function in asp that run correctly but If I tried to change it forasp.net in asp: xmlHTTP = CreateObject("Microsoft.XMLHTTP") And I thought to use this sentence for asp.net but the...
3
by: BjörnHolmberg | last post by:
I'm trying to consume a WS from Excel (Office 98), seems that I can't send arguments into the WS. In order to pinpoint the problem I've written the following application i C# and VB6. It reproduces...
5
by: Brent | last post by:
This AJAX stuff is all new to me. To try it out, I borrowed this code from a website: ======================== var http_request = false; function makeRequest(url) { http_request = false;
8
by: lopi | last post by:
Hello. I'm trying to remotely get a pdf file - http://remoteServer/file.pdf - in order to store it into another server, maybe with Scripting.FileSystemObject However the following code doesn't...
3
by: JMcCrillis | last post by:
I've implemented a FileUpload servlet using AJAX and JS. It appears to be working well but for one issue. I used XMLHTTP so I could intercept the response in Javascript and write it out to a field...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.