Monday, November 08, 2010 at 12:00 AM.


on uploadImageFile (f) {
		<<7/1/10; 6:26:47 AM by DW
	local (adrdata = scripting2suite.init ());
	local (username = adrdata^.editor.prefs.username);
	local (password = string (adrdata^.editor.prefs.password));
	local (server = string (adrdata^.editor.prefs.server));
	local (fname = file.filefrompath (f), ext = string.lower (string.lastfield (fname, ".")));
	if (ext == "gif") or (ext == "jpg") or (ext == "jpeg") {
		local (bits = file.readwholefile (f), type = user.webserver.prefs.ext2MIME.[ext]);
		local (atts = [server].scripting2.saveImage (username, password, fname, type, bits));
		adrdata^.editor.prefs.watchedFolder.whenLastUpload = ();
		adrdata^.editor.prefs.watchedFolder.urlLastUpload = atts.url;
		return (atts.url)}};
bundle { //test code
	url = uploadImageFile ("ohio:pictures:cmsdiagram.jpg");
	webbrowser.openurl (url)}

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.