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

using PUT with XMLHTTP

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
15 6850
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: fochie | last post by:
Greetings, I'm having a problem when I try to GET a file from my server via xmlhttp when using Mozilla. With IE I can get any type of file fine, get/display headers fine, etc. With Mozilla,...
6
by: Wescotte | last post by:
I've wrote a little test app to use XMLHTTPRquest test app but I'm looking to add some functionality and I'm not quite so how to go about doing it. Below is the source What I'd really like is...
7
by: pbd22 | last post by:
Hi. I am somewhat new to this and would like some advice. I want to search my xml file using "keyword" search and return results based on "proximity matching" - in other words, since the search...
3
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
10
by: neverquit | last post by:
hi , Iam Nagesh,Begineer in using Ajax,well i have been using ajax in application, i have faced a problem while placing the responseTEXT into the <div> tag positioned inside the <form> tag iam...
2
by: mukeshrasm | last post by:
hello i want to display the subjects on the same page based on class selected by user. i am using dropdown for classes. so when user will select a particular class then it will display subjects in...
20
by: vjayis | last post by:
hi when i m trying to fetch data from one page to another page using ajax, i get an error message in IE., but it runs well in firefox., could anyone help me., here is my javascript code., ...
5
by: perhapscwk | last post by:
I want to use ajax, by selected the option box, retrieve data from a .xml file and fill in to the textbox. below is the html page <script src="selectcd.js"></script> <form> Select a CD:...
6
by: tinman486 | last post by:
Im new to the whole javascript game, I know pretty much just enough to be dangerous with no real substance. Anyway Im trying to populate a DIV with a website using the URL as an inner html source ...
5
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.