User Guide

The HTTP API 33
Example
The following code gets an HTML file, saves all the files in the Configuration/Temp folder,
and then opens the local copy of the HTML file in a browser:
var httpReply = MMHttp.getFile("http://www.dreamcentral.com/¬
people/profiles/scott.html",
false);
if (httpReply.statusCode == 200){
var saveLoc = httpReply.data;
dw.browseDocument(saveLoc);
}
MMHttp.getFileCallback()
Description
This function gets the file at the specified URL, saves it in the Configuration/Temp folder
inside the Dreamweaver application folder, and then calls the specified function with the
request ID and reply result. When saving the file locally, Dreamweaver automatically creates
subfolders that mimic the folder structure of the server; for example, if the specified file is at
www.dreamcentral.com/people/index.html, Dreamweaver stores the index.html file in the
People folder inside the www.dreamcentral.com folder.
Arguments
callbackFunction, URL, {prompt}, {saveURL}, {titleBarLabel}
The callbackFunction argument is the name of the JavaScript function to call when the
HTTP request is complete.
The URL argument is an absolute URL on a web server; if http:// is omitted from the
URL, Dreamweaver assumes HTTP protocol.
The prompt argument, which is optional, is a Boolean value that specifies whether to
prompt the user to save the file. If
saveURL argument specifies a location outside the
Configuration/Temp folder, a
prompt value of false is ignored for security reasons.
The saveURL argument, which is optional, is the location on the users hard disk where
the file should be saved, which is expressed as a file:// URL. If prompt is a
true value or
saveURL is outside the Configuration/Temp folder, the user can override saveURL in the
Save dialog box.
The titleBarLabel argument, which is optional, is the label that should appear in the
title bar of the Save dialog box.
000_DW_API_Print.book Page 33 Wednesday, July 20, 2005 11:58 AM