function httpGetFile(url, port){
if(url.substr(0,7)=="http://")
url=url.substr(7);
if(!port) port=80;
var
domain=url.split("/")[0]+":"+port;
var
fileName=url.substr(url.lastIndexOf("/")+1);
var call="GET ";
if(url.indexOf("/")<0){
call+="/";
}else{
call+=url.substr(url.indexOf("/"));
}
call+=" HTTP/1.1\n";
call+="Host: "+domain+"\n\n";
var reply = new String();
var
file = new File();
file.encoding = "binary";
file.open("w");
var conn = new Socket();
conn.encoding = "binary";
if (conn.open
(domain, "binary")) {
conn.write (call);
reply =
conn.read(99999999999);
reply = reply.split("\r\n").join("\n");
reply = reply.split("\r").join("\n");
file.write(reply.substr(reply.indexOf("\n\n")+2));
file.close();
file.rename(fileName);
conn.close();
}else{
alert("CONNECTION TO DATABASE FAILED");
reply = "";
}
return file;
}
// EXAMPLE:
var
gotFile=httpGetFile("http://www.ps-scripts.com/bb/templates/subSilver/images/logo1.gif");
alert("GOT
FILE "+gotFile.length);
app.load(gotFile);