spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column50


Using JavaScript in HomeSite 4.0, Part III

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

The HTTPProvider Object's Methods, Part II

SaveReceivedStreamToFile(fileName, overwriteFlag)String

This method saves the received stream to a file, and overwrites an existing file if overwriteFlag is true. This method returns an error message upon failure. It returns "File already exists" when the given fileName exists and overwriteFlag is false. It returns "Path does not exist" when fileName is not found.

The following script reads an html page from a server and tries to save it to a local disk:

var app = Application;
function Main() {
  var app = Application;
  app.HTTPProvider.URL = "http://www.webreference.com/js/tips/990923.html";
  app.HTTPProvider.Get();
  var errorMsg = app.HTTPProvider.SaveReceivedStreamToFile
   ("d:\\yehuda\\990923.html", false );
  // (The above two lines should be joined as one line.
  // They have been split for formatting purposes.)
  if (errorMsg != "")
    {
     app.MessageBox("Save failed: " + errorMsg, "Save Error", 0);
    }
  app = null;
}

The first run of this script creates the file on the local disk. The second run will fail to overwrite the existing file because the overwriteFlag is false. This is the window that will pop up:

Post()None

Performs an HTTP POST method request.

Head()None

Performs an HTTP HEAD method request.

GetAsync()None

Performs an HTTP GET method request asynchronously.

PostAsync()None

Performs an HTTP POST method asynchronously.

HeadAsync()None

Performs an HTTP HEAD method request asynchronously.

Abort()None

Aborts the current HTTP operation.

URLEncode(stringValue)String

Converts a string to a URLEncoded format. Usefull when populating URL or FORM data.

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Created: October 11, 1999
Revised: October 15, 1999

URL: http://www.webreference.com/js/column50/httpmeth2.html