By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,638 Members | 2,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,638 IT Pros & Developers. It's quick & easy.

using PUT with XMLHTTP

P: n/a
Hi,

Do you know if it is possible to use the PUT method with the XMLHTTP
object and if yes what the client side code should look like?

I would like to PUT a file on the server. I got stuck here:

var ajax = new_ajax_obj();
ajax.open ('PUT', file, true);
ajax.send ('');

I failed to find a good documentation of the "send" method so that I
can specify a particular file.

Any help will be appreciated.

--
Kamen TOMOV
Jan 23 '06 #1
Share this Question
Share on Google+
15 Replies


P: n/a
To the best of my knowledge you cannot use PUT with the XmlHTTP object.
:-(

Sorry.

If you find out how, I'd love to know.

I've been using an iFrame for a similar effect.

Jan 24 '06 #2

P: n/a
Kamen TOMOV wrote:
Do you know if it is possible to use the PUT method with the XMLHTTP
object
The IXMLHTTPRequest interface reference[1] says it is possible, the XUL
Object Reference[2] says it is not. I have never tried anything else
than GET or POST to date.
and if yes what the client side code should look like?
I would like to PUT a file on the server. I got stuck here:

var ajax = new_ajax_obj();
ajax.open ('PUT', file, true);
ajax.send ('');

I failed to find a good documentation of the "send" method so that I
can specify a particular file.


You cannot specify a particular file there. If you want to use PUT, you
need a HTTP server and a resource that supports it (indicated by an
"Allow: ...,PUT" response header) and send it the _content_ of the file
you want to replace the resource with as the request body [as argument of
send()]. See RFC1945 (HTTP/1.0), appendix D, subsection 1.1.[3], and
RFC2616 (HTTP/1.1), subsection 9.6.[4] You will need additional host
objects for file access to retrieve that file content.[5]
HTH

PointedEars
___________
[1]
<URL:http://msdn.microsoft.com/library/en-us/xmlsdk/html/7924f6be-c035-411f-acd2-79de7a711b38.asp>
[2]
<URL:http://xulplanet.com/references/objref/XMLHttpRequest.html#method_open>
[3] <URL:http://www.rfc-editor.org/rfc/rfc1945.txt>
[4] <URL:http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html>
[5] <URL:http://xulplanet.com/references/xpcomref/group_Files.html>
<URL:http://msdn.microsoft.com/library/en-us/script56/html/jsobjfilesystem.asp>
Jan 24 '06 #3

P: n/a
On Tue, Jan 24 2006, Thomas 'PointedEars' Lahn wrote:
You will need additional host objects for file access to retrieve
that file content.[5]
..


And is there a generic JavaScript functionality that could be used for
reading a file beside using XUL?

Thank you.

--
Kamen TOMOV
Jan 24 '06 #4

P: n/a
VK

Kamen TOMOV wrote:
And is there a generic JavaScript functionality that could be used for
reading a file beside using XUL?

Thank you.


XPConnect (Gecko) / FileSystemObject (IE)

But FileSystemObject allows you to read only text files (TXT, XML,
HTTP). For binary files you're getting only file header. So no, there
is nothing universal / generic: except <input type="file"> and file
upload over HTTP in base64. This is fully universal and I'm affraid
this is what you'll have to live with for now. At least until any other
browser besides Amaya will support PUT method (I wouldn't count on it
too much).

Jan 24 '06 #5

P: n/a
Kamen TOMOV wrote:
On Tue, Jan 24 2006, Thomas 'PointedEars' Lahn wrote:
You will need additional host objects for file access to retrieve
that file content.[5]
..


And is there a generic JavaScript functionality that could be used for
reading a file beside using XUL?


As I said you have to use host objects for filesystem access (because
neither language discussed here provides for that feature natively). It is
possible to implement a generic interface with JS/ECMAScript to provide for
transparent file system access through it if either host object is
supported, but of course JavaScript does not provide for such an interface
natively.

It should be added that XMLHTTPRequest itself (which refers to another host
object) can provide for _read_ access to file content even if the local
system is not running a Web server, so you do not need the FileSystemObject
object or XUL filesystem objects for that necessarily; however, the Same
Origin Policy and other security restrictions apply in that case, too.

Please use _all_ the URLs I have provided and get informed first. Come back
again (and continue _this_ thread) if you have specific problems in making
your approach work.

<URL:http://jibbering.com/faq/>
PointedEars
Jan 24 '06 #6

P: n/a
On 2006-01-23, Kamen TOMOV <ka***@evrocom.net> wrote:
Hi,

Do you know if it is possible to use the PUT method with the XMLHTTP
object and if yes what the client side code should look like?

I would like to PUT a file on the server. I got stuck here:

var ajax = new_ajax_obj();
ajax.open ('PUT', file, true);
ajax.send ('');

I failed to find a good documentation of the "send" method so that I
can specify a particular file.

Any help will be appreciated.


PUT is not well supported (by servers), file uploads are usually done
using POST with multipart content and CGI support on ther server.
--

Bye.
Jasen
Jan 25 '06 #7

P: n/a
VK

Jasen Betts wrote:
PUT is not well supported (by servers), file uploads are usually done
using POST with multipart content and CGI support on ther server.


PUT is not supported *by current browsers* (except Amaya, but this W3C
ugly baby is not usable for browsing).

On the server side you can instruct server to accept even FOOBAR
requests if you want to, so again - it's the limitation from the client
side.

Jan 25 '06 #8

P: n/a
VK wrote:
Jasen Betts wrote:
PUT is not well supported (by servers), file uploads are usually done
using POST with multipart content and CGI support on ther server.
PUT is not supported *by current browsers*


Nonsense.
(except Amaya, but this W3C ugly baby is not usable for browsing).
Fortunately, you do not set the standards for the Web.
On the server side you can instruct server to accept even FOOBAR
requests
That would not be a _HTTP_ server anymore.
if you want to, so again - it's the limitation from the client side.


No, it is not. Learn to understand the difference between (HTTP) clients
and browsers.
PointedEars
Jan 25 '06 #9

P: n/a
VK

Thomas 'PointedEars' Lahn wrote:
VK wrote:
Jasen Betts wrote:
PUT is not well supported (by servers), file uploads are usually done
using POST with multipart content and CGI support on ther server.


PUT is not supported *by current browsers*


Nonsense.


Then please post here a *working* sample of PUT request using Firefox,
IE, Opera, Netscape, Camino, Safari (*any* of these, you don't need to
cover all of them).

A hint: you can do it with NCSA Mosaic, Netscape Composer (4.x package)
and W3C Amaya. What is the difference? That's your homework.

P.S. By "working sample" I did not mean a whole separate application
with an open interface accessed over JavaScript/JScript from a browser
page. This way JavaScript is capable for everything in the world: known
and unknown :-)

Jan 25 '06 #10

P: n/a
VK said the following on 1/25/2006 2:36 PM:
Thomas 'PointedEars' Lahn wrote:
VK wrote:
Jasen Betts wrote:
PUT is not well supported (by servers), file uploads are usually done
using POST with multipart content and CGI support on ther server.
PUT is not supported *by current browsers*

Nonsense.


Then please post here a *working* sample of PUT request using Firefox,
IE, Opera, Netscape, Camino, Safari (*any* of these, you don't need to
cover all of them).


Ummm, you missed the very important omission of saying it is not
supported by JScript, Javascript, or the venerable ECMAScript because
browsers *do* support PUT, just not through scripting.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 25 '06 #11

P: n/a
VK

Randy Webb wrote:
Ummm, you missed the very important omission of saying it is not
supported by JScript, Javascript, or the venerable ECMAScript because
browsers *do* support PUT


I *hate* to be pedantic but who missed to say that?
:-)

Jan 25 '06 #12

P: n/a
VK said the following on 1/25/2006 3:11 PM:
Randy Webb wrote:
Ummm, you missed the very important omission of saying it is not
supported by JScript, Javascript, or the venerable ECMAScript because
browsers *do* support PUT


I *hate* to be pedantic but who missed to say that?
:-)


I would tell you but then he would give me another vote for President of
the People called Troll by Thomas Lahn Club.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 25 '06 #13

P: n/a
VK
<offtopic>

VK wrote:
At least until any other browser besides
Amaya will support PUT method (I wouldn't count on
it too much).


Randy Webb wrote:
Ummm, you missed the very important omission of saying it is not
supported by JScript, Javascript, or the venerable ECMAScript because
browsers *do* support PUT
VK wrote:
I *hate* to be pedantic but who missed to say that?
:-)
Randy Webb wrote: I would tell you but then he would give me another vote for President of
the People called Troll by Thomas Lahn Club.


I'm sorry, I'm far away from running for doubtious credits for saying
something non-vitally important an instance before someone said
something equally non-important :-)

Just let you know that your last sentence ("I would tell...") allows 3
equally possible readings (over semantical analyzation) where A is
right, B is right, and both A and B are wrong. That's kind of sentence
one pays long bucks for in politics.

Just FYI

:-)

</offtopic>

Jan 25 '06 #14

P: n/a
VK wrote:
Thomas 'PointedEars' Lahn wrote:
VK wrote:
> Jasen Betts wrote:
>> PUT is not well supported (by servers), file uploads are usually done
>> using POST with multipart content and CGI support on ther server.
>
> PUT is not supported *by current browsers*

Nonsense.


[...] you can do it with [...] W3C Amaya. What is the difference? That's
your homework.


If you would have done your homework, I would not have to point out that
e.g. the latest Amaya versions (9.3/8.8.3) were released December 9, 2005.
In case you have problems with your calendar: That was 9 days _after_ the
latest Firefox release. The support for HTTP PUT was introduced in Amaya
version 7.2 (February 3, 2003), BTW.

<URL:http://www.w3.org/Amaya/User/New.html>
PointedEars
Jan 25 '06 #15

P: n/a
VK said the following on 1/25/2006 5:10 PM:
<offtopic>

VK wrote:
At least until any other browser besides
Amaya will support PUT method (I wouldn't count on
it too much).
Randy Webb wrote:
Ummm, you missed the very important omission of saying it is not
supported by JScript, Javascript, or the venerable ECMAScript because
browsers *do* support PUT
VK wrote: I *hate* to be pedantic but who missed to say that?
:-)
Randy Webb wrote:> I would tell you but then he would give me another vote for President of
> the People called Troll by Thomas Lahn Club.


I'm sorry, I'm far away from running for doubtious credits for saying
something non-vitally important an instance before someone said
something equally non-important :-)


I stopped worrying about TL calling me a troll long ago. It happens so
often that it has lost it's meaning.
Just let you know that your last sentence ("I would tell...") allows 3
equally possible readings (over semantical analyzation) where A is
right, B is right, and both A and B are wrong. That's kind of sentence
one pays long bucks for in politics.

Just FYI


Maybe I should consider becoming a political writer. Hmmmmmm

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 26 '06 #16

This discussion thread is closed

Replies have been disabled for this discussion.